Module talk:Redirect hatnote
Request a new tracking category
@Mr. Stradivarius: Hi. I noticed module:redirect, which has different functionality from template:redirect, and was wanting to modify the latter to use the former to check for and track "incorrect redirects". So I went to Template:Redirect/sandbox to work on that and found it pointing me here. So, since you're converting it to Lua maybe you can do this. For example, pretend that an editor put a {{redirect}} hatnote on Computer that said Calculator redirects here. That wouldn't be a missing redirect because Calculator exists as a separate article. Or they might put up a hatnote that says Digital calculator redirects here. That's a redirect, but it redirects to a different article. Can you make this module check for those, and have them populate a category like Category:Incorrect redirects. Thanks, Wbm1058 (talk) 19:27, 15 May 2014 (UTC)
- @Wbm1058: I've added the code to the module. — Mr. Stradivarius ♪ talk ♪ 21:51, 15 May 2014 (UTC)
- Thanks! Wbm1058 (talk) 21:59, 15 May 2014 (UTC)
@Mr. Stradivarius: What is the status of the enhancements to populate Category:Invalid redirects? Does Module:Redirect need changes to support this? Wbm1058 (talk) 21:45, 25 July 2014 (UTC)
- @Wbm1058: Module:Redirect hatnote itself hasn't been deployed, which is why nothing is showing up in the category. I won't be around much on WP much this week though, so I won't be able to get round to it straight away. — Mr. Stradivarius on tour ♪ talk ♪ 15:16, 26 July 2014 (UTC)
- @Mr. Stradivarius: Thanks much! Category:Invalid redirects now has over 240 pages, and I've already started fixing them. Wbm1058 (talk) 23:06, 5 August 2014 (UTC)
- ...and it's now been emptied. But it won't stay empty for long, this is one that needs constant patrolling. A shout out of thanks to BD2412 for helping, though their entry to this list is User:RussBot/Invalid redirect hatnotes/001, which I only discovered after starting work on this cleanup task. So now we have part of that bot's functions being done in real-time here. Wbm1058 (talk) 15:55, 26 August 2014 (UTC)
- Will this category also catch instances of people adding a hatnote that, for example, says that "Computer" redirects to "Computer"? bd2412 T 01:56, 27 August 2014 (UTC)
- I noticed that there were cases that the bot was flagging that were not being categorized as either missing or invalid redirects. Maybe the next bot run will help us spot the cases that are not getting categorized yet. Wbm1058 (talk) 11:56, 28 August 2014 (UTC)
- That instance isn't caught currently. Let me make a quick list of all the possibilities I can think of:
- The first parameter specifies a page which doesn't exist (covered in Category:Missing redirects)
- The first parameter specifies a page which does exist, but isn't a redirect (not covered)
- The first parameter specifies the current page (not covered)
- The first parameter specifies a redirect that goes somewhere other than the current page (covered in Category:Invalid redirects)
- The first parameter specifies an invalid title (not covered)
- These would all be fairly easy to add categories for. Maybe put no. 2 in Missing redirects, and nos. 3 and 5 in Invalid redirects? — Mr. Stradivarius ♪ talk ♪ 12:23, 28 August 2014 (UTC)
- And another possibility (no. 6) - cross-namespace redirects to mainspace where the "selfref" option isn't set. Not sure if this is very common though, and would probably need a separate category. Thoughts? — Mr. Stradivarius ♪ talk ♪ 12:27, 28 August 2014 (UTC)
- Will this category also catch instances of people adding a hatnote that, for example, says that "Computer" redirects to "Computer"? bd2412 T 01:56, 27 August 2014 (UTC)
- ...and it's now been emptied. But it won't stay empty for long, this is one that needs constant patrolling. A shout out of thanks to BD2412 for helping, though their entry to this list is User:RussBot/Invalid redirect hatnotes/001, which I only discovered after starting work on this cleanup task. So now we have part of that bot's functions being done in real-time here. Wbm1058 (talk) 15:55, 26 August 2014 (UTC)
- @Mr. Stradivarius: Thanks much! Category:Invalid redirects now has over 240 pages, and I've already started fixing them. Wbm1058 (talk) 23:06, 5 August 2014 (UTC)
Category:Redirects to the main namespace has just 43 members, but I don't know whether there is anything checking for such redirects that are missing {{R to main}} templates. Template:Selfref seems primarily intended for redirects from Main to Wikipedia project space.
No. 3 is just a special case of no. 2 – a page which does exist, but isn't a redirect. The current page must exist to have a hatnote on it. I would put them all in the invalid category. No. 5 is a special case of no. 1 – an invalid title can't exist by definition. I'm thinking those should be missing – a page that needs to be created like red-links (but can't be). But these would be rare, and could go in either category. I don't think it matters that much which. – Wbm1058 (talk) 18:05, 28 August 2014 (UTC)
- @Wbm1058: there's no problem with having redirects from other namespaces to mainspace per se. The problem is that when you have a redirect from another namespace to mainspace, and you highlight that fact with the {{redirect}} template, the text at the start of the hatnote says "Wikipedia:Foo redirects here". If the hatnote div doesn't have the "selfref" class, then this will show up in print versions of articles, etc., which we want to avoid. Now, all the hatnote templates that have been converted to Lua have a
|selfref=yes
parameter (currently undocumented here, sorry), which adds the selref class to any hatnote that specifies it. So my thought was that we could output a category on pages where this happened so that we could fix them. But on typing this out, I've realised the more obvious solution - we can just add the selfref class in the module for cross-namespace redirects like this without having to worry about outputting categories at all. I'll go and add that code in now.As for your other error category suggestions, they all sound sensible, and I'll add those to the module as well. — Mr. Stradivarius ♪ talk ♪ 07:39, 5 September 2014 (UTC)
- @Mr. Stradivarius: Great. Bream was restored as an article on 16 August 2014. User:RussBot/Invalid redirect hatnotes picked up the fact that Common bream has an invalid hatnote, but that wasn't categorized. – Wbm1058 (talk) 21:25, 24 September 2014 (UTC)
- @Wbm1058: I hadn't got around to finishing the test cases and updating the module. I've done it now, and Common bream is now in Category:Invalid redirects. — Mr. Stradivarius ♪ talk ♪ 02:00, 25 September 2014 (UTC)
- Thanks! That reported some forty or so more pages with redirect issues, and I've fixed most of them. No issues with the module code, it's working very well. – Wbm1058 (talk) 18:53, 25 September 2014 (UTC)
- @Wbm1058: I hadn't got around to finishing the test cases and updating the module. I've done it now, and Common bream is now in Category:Invalid redirects. — Mr. Stradivarius ♪ talk ♪ 02:00, 25 September 2014 (UTC)
For the record, following Wikipedia:Categories for discussion/Log/2015 February 21, the tracking category has been moved from "invalid redirects" to Category:Articles with redirect hatnotes needing review. – Fayenatic London 11:30, 2 March 2015 (UTC)
Bug with "other uses"
{{redirect|Paper folding|other uses|Paper folding (disambiguation)|other uses of Origami|Origami (disambiguation)}}
gives:
- "Paper folding" redirects here. For other uses, see Paper folding (disambiguation).
Live example:
When the second parameter equals "other uses", the fourth and subsequent parameters are ignored. -- [[User:Edokter]] {{talk}}
12:15, 12 November 2014 (UTC)
- @Edokter: I seem to remember I wrote it like that to stop it from outputting things like '"Paper folding" redirects here. For other uses, see Foo. For other uses, see Paper folding (disambiguation).' I was assuming that the natural way to phrase things like this would be '"Paper folding" redirects here. For other uses of Origami, see Origami (disambiguation). For other uses, see Paper folding (disambiguation).' But perhaps the module shouldn't force the order like this? — Mr. Stradivarius ♪ talk ♪ 14:12, 12 November 2014 (UTC)
I'm stumped
Why is Wikipedia:Requested moves in Category:Invalid redirects? I cannot figure out what's causing this categorization. It's been there for nearly a month now, as I recall. – Wbm1058 (talk) 19:42, 28 February 2015 (UTC)
- Given that the category doesn't appear on Wikipedia:Requested moves itself, and that Wikipedia:Requested moves persisted in Category:Invalid redirects after I gave both pages a null edit, this looks like a MediaWiki bug rather than a module bug. Try filing a report in Phabricator to get one of the devs to look at it. Also, pinging Anomie as I remember he was interested in investigating a similar bug before. — Mr. Stradivarius ♪ talk ♪ 01:42, 1 March 2015 (UTC)
- The page that's in the category is this one, one of the pages created due to phab:T87645. The simplest thing to do for that particular case might be to use the API action=delete with pageid rather than title to just delete it. Anomie⚔ 21:21, 1 March 2015 (UTC)
- I'm glad someone had picked this up. I've processed the renaming of the category to Category:Articles with redirect hatnotes needing review but that RM page is still in the old one. I'll leave it to you to follow it up, as you seem to have more technical knowledge than me. – Fayenatic London 11:32, 2 March 2015 (UTC)
- I've just deleted the phantom page. Thanks to Anomie for pointing out what to do. :) — Mr. Stradivarius ♪ talk ♪ 13:08, 2 March 2015 (UTC)
- I'm glad someone had picked this up. I've processed the renaming of the category to Category:Articles with redirect hatnotes needing review but that RM page is still in the old one. I'll leave it to you to follow it up, as you seem to have more technical knowledge than me. – Fayenatic London 11:32, 2 March 2015 (UTC)
- The page that's in the category is this one, one of the pages created due to phab:T87645. The simplest thing to do for that particular case might be to use the API action=delete with pageid rather than title to just delete it. Anomie⚔ 21:21, 1 March 2015 (UTC)
Multiple redirects
To implement more of the redirect hatnotes with this module, I've started work on some tweaks in the sandbox that change the module a bit. To summarize:
- An invocation argument is added to the
p.redirect
function, specifying a number of redirects to look for (defaulting to 1) - The
redirect
variable is assumed throughout to be a table of strings instead of a string.
I'm not quite done; some of the code hasn't been tweaked yet, i.e. the tracking category and options sections towards the end. Also, I'm a total newbie to Lua, so there's a decent chance I've inserted bugs somewhere. Anyway, I've got to go do other things for a bit, so I figure this is the natural time to ask for input on the tweaks I've started on. Questions, comments, ideas? Have I broken everything forever? :) {{Nihiltres |talk |edits}} 19:57, 24 March 2016 (UTC)
- I think it's probably ready to deploy, but I'd appreciate it if someone can take a look over the changes first and give a thumbs up. {{Nihiltres |talk |edits}} 22:51, 27 March 2016 (UTC)
Desirable defaulting behaviour?
I've written some code, now available as an alpha module at Module:Hatnote list, intended to centralize the mechanism for generating the lists of "For X, see [[Y]]
" statements that are used in templates like {{about}}, {{redirect}}, and their variants. I based it on {{about}}'s behaviour, assuming that they were the same, but … when examining the results as applied to {{redirect}}, using Module:Redirect hatnote/sandbox and Template:Redirect/testcases, I noticed this discrepancy:
{{redirect|REDIRECT|USE1|PAGE1|USE2}}
→{{redirect/sandbox|REDIRECT|USE1|PAGE1|USE2}}
→
Compare the behaviour found in {{about}}:
{{about|ABOUT|USE1|PAGE1|USE2}}
→
The behaviour is definitely intended, based on the isFirst
parameter of formatUseTable()
(see in particular lines 102–110) that sets the behaviour differently for the first item in the use table, such that:
{{redirect|REDIRECT|USE1}}
→{{redirect/sandbox|REDIRECT|USE1}}
→
It seems odd. I'd prefer to simplify things by getting rid of the isFirst
behaviour; it seems awkward and it means you can't conveniently end a template with |other uses}}
, or even with ||REDIRECT (disambiguation)}}
, to produce a terminal "For other uses, see [[REDIRECT (disambiguation)]]
":
{{redirect|REDIRECT|USE1|PAGE1|other uses}}
→{{redirect|REDIRECT|USE1|PAGE1||REDIRECT (disambiguation)}}
→{{redirect/sandbox|REDIRECT|USE1|PAGE1|other uses}}
→{{redirect/sandbox|REDIRECT|USE1|PAGE1||REDIRECT (disambiguation)}}
→
Of course, I could be completely wrong, hence bringing this up for discussion rather than changing this unilaterally—so, is there a good reason it does and should default that way? Are there a significant number of pages making use of the behaviour? {{Nihiltres |talk |edits}} 03:52, 11 April 2016 (UTC)
- I think you're right to use {{about}} as the gold-standard for hatnote syntax and behavior. I believe that any inconsistencies likely arose from the original templates being coded at different times by different people, though I haven't analyzed the history in depth, and the original port to Lua modules simply maintained the existing inconsistencies. I'm not quite following what you're saying, putting the differences in terms of module logic, but as I'm well aware of a significant difference, I'll explain that below, and you can confirm whether we're on the same page.
- I often encounter simple {{redirect}} hatnotes such as this:
{{redirect|Module talk:Redirect hatnote/doc|hats|Hat}}
, which displays this:
- Sometimes the hatnote states the obvious, such as when the title of the article "redirects" to the title of the article. I simplify those by replacing {{redirect}} with {{for}}:
{{for|hats|Hat}}
, which displays this:
- ...which is equivalent to:
{{about||hats|Hat}}
- ...which is equivalent to:
- But when there is a second "
For X, see [[Y]]
" statement:{{redirect|Module talk:Redirect hatnote/doc|hats|Hat|notes|Note}}
, which displays this:
{{for|hats|Hat|notes|Note}}
displays this:
- so I need to change it to {{about}} to get the desired behavior:
{{about||hats|Hat|notes|Note}}
displays this:
- To get the "for" behavior in "about"
{{about||hats|Hat|and|notes|and|Note}}
doesn't work. It only shows the first two:
- Oh, now I see that {{for}} and {{about}} don't use Lua. But somehow this difference came to my mind. It's the inconsistency I encounter most often.
- Of course,
{{for|
is more readable and intuitive than{{about||
– wbm1058 (talk) 13:42, 11 April 2016 (UTC)
- So, getting back to the inconsistency that you pointed out:
{{redirect|Module talk:Redirect hatnote/doc|Hats|hat|Notes}}
→{{about||Hats|hat|Notes}}
→- Right, this is not good, but here I think the {{redirect}} behavior is preferred. I'm not even seeing this permutation of {{about}} is the documentation, so I'm not sure its use was anticipated or intended. It makes more sense to use
{{about||Hats|hat|other uses}}
→- if one wants to link to Redirect hatnote (disambiguation). – wbm1058 (talk) 14:37, 11 April 2016 (UTC)
- Getting {{for}} and {{about}} to use Lua is one of my goals, and it'll actually address one of the issues you noted:
{{about||USE1|PAGE1|and|PAGE2|and|PAGE3}}
→{{about/sandbox||USE1|PAGE1|and|PAGE2|and|PAGE3}}
→
- More broadly, it'll be worth hashing out at some point the kinds of lists that hatnotes use. As I see it, there are three types: the and-list (a list of one or more pages, joined by "and" as needed), the or-list (a list of one or more pages joined by "or" as needed) and the for-see list (a list of "For X, see Y"'s, where "X" is a topic/use and "Y" is itself an and-list of target pages.) {{For}} is confusing precisely because it looks like a for-see list but behaves as an and-list. The purpose of eliminating the
isFirst
behaviour in {{redirect}} is to make all for-see lists act more or less the same. :) - Anyway … I think we should try adding a tracking category to check the prevalence of this usage. I'm betting that few cases use it. This use patterns itself neatly to cases where there are an odd number of arguments past the redirect arguments, so we should be able to add a quick snippet to track the behaviour:
if (#args - numRedirects) % 2 == 1 then addCategory('Hatnote templates using unusual parameters') end
- We might want to use a more specific category (there's other stuff in the "unusual parameters" category already), but that would give us a good sense of existing usage. That seem like a good idea? {{Nihiltres |talk |edits}} 21:37, 11 April 2016 (UTC)
- Wow, another tracking cat I hadn't heard of before. Category:Hatnote templates using unusual parameters has been around since it was added to {{About}} on 26 February 2011. I'd just use that one rather than create another; we already have more tracking categories than anyone can keep track of. – wbm1058 (talk) 00:33, 12 April 2016 (UTC)
- Getting {{for}} and {{about}} to use Lua is one of my goals, and it'll actually address one of the issues you noted:
- Beanie (seamed cap) has been in that category since 1 April 2012. It's the only mainspace page in the cat. – wbm1058 (talk) 00:59, 12 April 2016 (UTC)
- This simple grammar fix cleared the category. I would have to fire up more brain cells to figure out how the {{about}} template processed that! wbm1058 (talk) 01:17, 12 April 2016 (UTC)