Jump to content

Module talk:Check for unknown parameters

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by MSGJ (talk | contribs) at 14:19, 4 September 2024 (Suggested enhancement: new section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Lua patterns

Is it possible to add a function to use Lua patterns and also limit the number? For example, if the parameter |date= can be between |date1= and |date8= and using regexp1 = "date[%d]+" and something like reglimit1=8 to limit the allowed parameters? Gonnym (talk) 12:26, 23 June 2024 (UTC)[reply]

Why not write a specific pattern? regexp1 = "date[1-8]"
Trappist the monk (talk) 12:59, 23 June 2024 (UTC)[reply]
Didn't even cross my mind to do that for some reason. I'll try that out, thanks! Gonnym (talk) 13:01, 23 June 2024 (UTC)[reply]
@Trappist the monk doesn't work. Tested it on TNA Impact! by using the /sandbox version in preview. Gonnym (talk) 13:06, 23 June 2024 (UTC)[reply]
Nevermind, got it to work without the quotes of course. I'll update the /doc here. Gonnym (talk) 13:09, 23 June 2024 (UTC)[reply]
You could also look at the check at {{Interlinear}} for a fun example. It supports values of 1–99 for some parameters (actually 1 and higher, but I'm hoping nobody will put in more than 99 unnamed parameters). – Jonesey95 (talk) 19:43, 24 June 2024 (UTC)[reply]
The pattern [1-9][%d]* (should probably be written [1-9]%d*) is not limited to the range 1–99. %d* means 0 or more digits. So, as long as the first digit is not zero, any number of digits (within reason) will be accepted. If you want to actually limit the range to 1–99 you might use %f[%d][1-9]%d?$ where (right to left) $ anchors the pattern to the end of the parameter name string; %d? means 0 or 1 digits; [1-9] requires the first digit of the enumeration to be in the range 1–9; %f[%d] is the frontier pattern where the next character is a digit but the previous character is not a digit – in abc123 the pattern finds the boundary between c (parameter name) and 1 (first digit of the enumerator).
Trappist the monk (talk) 22:00, 24 June 2024 (UTC)[reply]

Protected edit request on 29 August 2024

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)[reply]

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)[reply]

Suggested enhancement

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)[reply]