Module talk:Check for unknown parameters

Entry point for other modules [ edit ]

Could the maintainers of this module add a function to allow other modules (not templates) to use this? Would be very helpful for me. --Gonnym (talk) 15:24, 25 December 2019 (UTC)

I've gone ahead and edited the sandbox to enable this. I've added basic tests to the testcases to show it still works. Again, these are basic tests as this page wasn't setup at all so there are no previous tests to compare. Please review code and tests. --Gonnym (talk) 19:14, 29 December 2019 (UTC)

Out of curiosity, where would you be using this feature? * Pppery * it has begun... 19:48, 31 December 2019 (UTC)
When needed in modules, same as it's usage in templates. I've written a few modules myself where they are needed. --Gonnym (talk) 10:42, 1 January 2020 (UTC)
Again, I would appreciate an example. It seems like the concept of checking for unknown parameters only makes sense for Wikitext arguments, at which point you're likely to have a frame object around anyway so a separate Lua interface is not needed. * Pppery * it has begun... 04:23, 2 January 2020 (UTC)
As a recent example, see getUnknownParametersErrors(args) at Module:Redirect template handler/sandbox. However from reading into your question (and if I'm mistaken, then apologies), I think we differ on design philosophy. Even if that module was called by 1 template (which it isn't), I'd still want the code in the module and not the template. Trying to write code that is close as possible in Wikipedia to some sort of MVC or similar approach, means that when I write a module, I don't want the actual template to have any logic, which includes using this module. --Gonnym (talk) 10:00, 2 January 2020 (UTC)
You're right that we differ in design philosophy (this was already known since February, however you did misunderstand my suggestion, which was to call Module:Check for unknown parameters from Lua, passing it a frame object. The usecase of one submodule handling argument parsing for many different parents modules such as Module:Redirect template handler (sidenote: which really needs a less generic name) does make my suggestion not feasible, however.

From a coding point of view, what is the point of the type checks on args and pargs? The module does nothing useful unless both parameters are given as tables, and it seems better to me to raise an error rather than do nothing when given bad data. * Pppery * it has begun... 20:28, 2 January 2020 (UTC)
Regarding the type check, I agree with you that an error is better and to be honest, would be much better to handle that check right at the beginning of the function before any parameter validation is done. If you prefer that the default module failure error handle this instead, I have no issues with that. --Gonnym (talk) 20:47, 2 January 2020 (UTC)

Request disabled due to lack of consensus. Gonnyn: as a template editor you can make this change yourself if/when you have support for the change. — Martin (MSGJ · talk) 14:12, 6 January 2020 (UTC)

Seems quite a strange close. There was no one opposing and only Pppery who was engaging in a discussion, which means that per WP:SILENCE there was no "lack of consensus". I placed the template so someone other than myself can take a look at the code so closing it is counter-productive, but what's done is done. --Gonnym (talk) 14:32, 6 January 2020 (UTC)
@MSGJ: There is definitely no "lack of consensus" here. * Pppery * it has begun... 23:18, 6 January 2020 (UTC)
Thanks both for confirming your opinions and sorry if I misread the discussion. It looked like a fundamental disagreement on the way forward! If the sandbox is ready I can deploy, or Gonnym can do it. — Martin (MSGJ · talk) 11:05, 7 January 2020 (UTC)
Thanks MSGJ and Pppery, I'll do it later today when I have time. --Gonnym (talk) 11:51, 7 January 2020 (UTC)
 Note: Closing request per Gonnym's comment. qedk (t c) 17:46, 7 January 2020 (UTC)

False warning of unknown parameter [ edit ]

This module seems to be giving a false claim of an unknown parameter for Template:Infobox disputed islands. You can see this in the usage on James Shoal if you open the edit window and then click the Preview button. Any ideas why it's giving this error? The parameter is clearly in the template, and I've added it to the docs and the Wikidata entry, so I'm not sure what else to do. ···日本穣 · 投稿 · Talk to Nihonjoe · Join WP Japan! 16:54, 22 July 2020 (UTC)

@MSGJ: as the most likely to know. ···日本穣 · 投稿 · Talk to Nihonjoe · Join WP Japan! 16:55, 22 July 2020 (UTC)
Fixed. All valid parameters need to be added to the parameter check at the bottom of the template. I have added |type=. Also, please put the Template Data programming code into the /doc template, not into the template itself. Take a look at Template:Infobox organization/doc to see how it is normally done. – Jonesey95 (talk) 17:46, 22 July 2020 (UTC)
@Jonesey95: Fixed, I believe. I'm not sure who put that into the template (I haven't looked in the history). Please review the changes to Template:Infobox disputed islands and Template:Infobox disputed islands/doc to make sure I did it correctly. Thanks! ···日本穣 · 投稿 · Talk to Nihonjoe · Join WP Japan! 18:33, 22 July 2020 (UTC)
The documentation looks better. I think you did it correctly. – Jonesey95 (talk) 18:44, 22 July 2020 (UTC)
What is this?