Module talk:Check for unknown parameters: Difference between revisions
m Archiving 1 discussion(s) to Module talk:Check for unknown parameters/Archive 1) (bot |
m Archiving 1 discussion(s) to Module talk:Check for unknown parameters/Archive 1) (bot |
||
(33 intermediate revisions by 14 users not shown) | |||
Line 1: | Line 1: | ||
{{Permanently protected}} |
{{Permanently protected}} |
||
⚫ | |||
{{oldtfdfull|date= 2019 December 30 |result=no consensus |disc=Module:Check for deprecated parameters|merge=self}} |
{{oldtfdfull|date= 2019 December 30 |result=no consensus |disc=Module:Check for deprecated parameters|merge=self}} |
||
{{talk header}} |
{{talk header}} |
||
{{WikiProject banner shell| |
|||
⚫ | |||
}} |
|||
{{User:MiszaBot/config |
{{User:MiszaBot/config |
||
| algo=old(90d) |
| algo=old(90d) |
||
Line 13: | Line 15: | ||
}} |
}} |
||
== |
== Protected edit request on 29 August 2024 == |
||
{{edit fully-protected|Module:Check for unknown parameters|answered=yes}} |
|||
Would it be possible to distinguish between ''unknown'' and ''deprecated'' parameters? It would be useful sometimes to track deprecated parameters in a different category, or with a different preview message. — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 20:17, 4 December 2023 (UTC) |
|||
On [[Module:Check_for_unknown_parameters#L-94]], please replace the undefined variable <code>preview</code> with <code>preview_text</code>. That expression is always going to evaluate to true and so will never reach the third expression. [[User:Awesome Aasim|Awesome]] [[User_talk:Awesome Aasim|Aasim]] 17:57, 29 August 2024 (UTC) |
|||
:[[:Module:Check for deprecated parameters]]. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 16:06, 5 December 2023 (UTC) |
|||
:Done. Also added <syntaxhighlight lang="wikitext" inline="1">require ('strict')</syntaxhighlight> which will catch other globals. Keep an eye on {{cl|Pages with script errors}} to see if the addition reveals other globals. |
|||
⚫ | |||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 18:08, 29 August 2024 (UTC) |
|||
== Suggested enhancement == |
|||
== Error category should also be added in preview == |
|||
{{see also|Module_talk:WikiProject banner}} |
|||
If there is an error category for unknown parameters then it's only added in the rendered page, not previews which instead show a preview warning. That can be very confusing. Consider for example [[Copa Libertadores Femenina]] ([https://en.wikipedia.org/enwiki/w/index.php?title=Copa_Libertadores_Femenina&oldid=1181533151 permanent link]) with [[:Category:Pages using flagicon template with unknown parameters]]. The page has 135 {{tl|flagicon}}. The unknown parameter is in <code><nowiki>{{flagicon|BRA|side=30px}}</nowiki></code> (should have said size). It's common to track down where a category is added by previewing different parts of the code. That fails here when the category is never added in preview. You can search for the preview warning in the preview but users may not know that. Previews can add things but shouldn't remove things. [[User:PrimeHunter|PrimeHunter]] ([[User talk:PrimeHunter|talk]]) 11:36, 9 December 2023 (UTC) |
|||
We are using this module on [[Module:WikiProject banner]]. We first check if [[:Category:Pages using WikiProject PROJECT with unknown parameters]] exists and if not, then we use [[:Category:WikiProject templates with unknown parameters]] instead. The problem is that this is causing thousands of links to non-existent categories to be recorded, which can be seen in [[Special:WantedPages]]. My suggestion is as follows. The module can accept an additional argument called <code>fallback</code> which is a category which will be used if the one specified in <code>unknown</code> does not exist. In this way we can check existence of that category only when unknown parameters are discovered, not in every single case. — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 14:19, 4 September 2024 (UTC) |
|||
:What is it that I'm missing? If the problem is caused by something that happens in [[Module:WikiProject banner]], that is where the fix should be applied. Adding miscellaneous one-off patches to this module is not a good idea. When you switch to the default category, you know that the preferred category does not exist so why link to it? Link to the preferred category only when it exists. |
|||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 15:35, 4 September 2024 (UTC) |
|||
::I'll try and explain better. Or you can look at the code at around [[Module:WikiProject banner#L-831]]. We have to check existence before calling this module. Checking existence adds a link to the page. Therefore every transclusion of {{tl|WikiProject Lepidoptera}} is generating a link to [[:Category:Pages using WikiProject Lepidoptera with unknown parameters]] which is not so good. I would prefer to only check if the category exists if there are some unknown parameters. That check can only happen in this module. Or perhaps you have a better idea — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 21:02, 4 September 2024 (UTC) |
|||
:::I haven't taken any real time to study the code (it has taken me more time to write this than I spent looking at the code) but [[Module:Check_for_unknown_parameters#L-113|Module:Check for unknown parameters line 113]] appears to return a concatenated string of unknown parameters (apparently without delimiters). If there are no unknowns then the <syntaxhighlight lang="lua" inline="1">table.concat(res)</syntaxhighlight> returns an empty string. So, it looks like <syntaxhighlight lang="lua" inline="1">p._check(args, pargs)</syntaxhighlight> returns: |
|||
::::<code>nil</code> when either of <code>args</code> and <code>pargs</code> is not a table |
|||
::::<code>''empty string''</code> when there are no unknown parameters |
|||
::::some sort of list of unknown parameters |
|||
:::If this is true then you should be checking the returned value from <syntaxhighlight lang="lua" inline="1">require('Module:Check for unknown parameters')._check(parameters, parent_args)</syntaxhighlight> before you fiddle about with categories. |
|||
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:22, 4 September 2024 (UTC) |
|||
⚫ | |||
::::Yes that works. Unfortunately it means that I need to call the module twice: the second time after deciding which category to use. But this will only happen if there are any unknown parameters so will not affect performance unduly. — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 09:06, 5 September 2024 (UTC) |
|||
:::::Add comments to your code. When you are crushed by a steamroller while jaywalking Main Street, whoever comes after you to maintain that module can then know why you did what you did. |
|||
:::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 11:48, 5 September 2024 (UTC) |
Latest revision as of 20:03, 23 September 2024
Module:Check for unknown parameters is permanently protected from editing because it is a heavily used or highly visible module. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit protected}} to notify an administrator to make the requested edit.
|
This module was considered for merging on 2019 December 30. The result of the discussion was "no consensus". |
This is the talk page for discussing improvements to the Check for unknown parameters module. |
|
Archives: 1Auto-archiving period: 3 months |
This module does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
|
Protected edit request on 29 August 2024
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
On Module:Check_for_unknown_parameters#L-94, please replace the undefined variable preview
with preview_text
. That expression is always going to evaluate to true and so will never reach the third expression. Awesome Aasim 17:57, 29 August 2024 (UTC)
- Done. Also added
require ('strict')
which will catch other globals. Keep an eye on Category:Pages with script errors to see if the addition reveals other globals. - —Trappist the monk (talk) 18:08, 29 August 2024 (UTC)
Suggested enhancement
[edit]We are using this module on Module:WikiProject banner. We first check if Category:Pages using WikiProject PROJECT with unknown parameters exists and if not, then we use Category:WikiProject templates with unknown parameters instead. The problem is that this is causing thousands of links to non-existent categories to be recorded, which can be seen in Special:WantedPages. My suggestion is as follows. The module can accept an additional argument called fallback
which is a category which will be used if the one specified in unknown
does not exist. In this way we can check existence of that category only when unknown parameters are discovered, not in every single case. — Martin (MSGJ · talk) 14:19, 4 September 2024 (UTC)
- What is it that I'm missing? If the problem is caused by something that happens in Module:WikiProject banner, that is where the fix should be applied. Adding miscellaneous one-off patches to this module is not a good idea. When you switch to the default category, you know that the preferred category does not exist so why link to it? Link to the preferred category only when it exists.
- —Trappist the monk (talk) 15:35, 4 September 2024 (UTC)
- I'll try and explain better. Or you can look at the code at around Module:WikiProject banner#L-831. We have to check existence before calling this module. Checking existence adds a link to the page. Therefore every transclusion of {{WikiProject Lepidoptera}} is generating a link to Category:Pages using WikiProject Lepidoptera with unknown parameters which is not so good. I would prefer to only check if the category exists if there are some unknown parameters. That check can only happen in this module. Or perhaps you have a better idea — Martin (MSGJ · talk) 21:02, 4 September 2024 (UTC)
- I haven't taken any real time to study the code (it has taken me more time to write this than I spent looking at the code) but Module:Check for unknown parameters line 113 appears to return a concatenated string of unknown parameters (apparently without delimiters). If there are no unknowns then the
table.concat(res)
returns an empty string. So, it looks likep._check(args, pargs)
returns:nil
when either ofargs
andpargs
is not a tableempty string
when there are no unknown parameters- some sort of list of unknown parameters
- If this is true then you should be checking the returned value from
require('Module:Check for unknown parameters')._check(parameters, parent_args)
before you fiddle about with categories. - —Trappist the monk (talk) 22:22, 4 September 2024 (UTC)
- Great, thanks. I'll look into that — Martin (MSGJ · talk) 08:55, 5 September 2024 (UTC)
- Yes that works. Unfortunately it means that I need to call the module twice: the second time after deciding which category to use. But this will only happen if there are any unknown parameters so will not affect performance unduly. — Martin (MSGJ · talk) 09:06, 5 September 2024 (UTC)
- Add comments to your code. When you are crushed by a steamroller while jaywalking Main Street, whoever comes after you to maintain that module can then know why you did what you did.
- —Trappist the monk (talk) 11:48, 5 September 2024 (UTC)
- I haven't taken any real time to study the code (it has taken me more time to write this than I spent looking at the code) but Module:Check for unknown parameters line 113 appears to return a concatenated string of unknown parameters (apparently without delimiters). If there are no unknowns then the
- I'll try and explain better. Or you can look at the code at around Module:WikiProject banner#L-831. We have to check existence before calling this module. Checking existence adds a link to the page. Therefore every transclusion of {{WikiProject Lepidoptera}} is generating a link to Category:Pages using WikiProject Lepidoptera with unknown parameters which is not so good. I would prefer to only check if the category exists if there are some unknown parameters. That check can only happen in this module. Or perhaps you have a better idea — Martin (MSGJ · talk) 21:02, 4 September 2024 (UTC)