Jump to content

Module talk:Redirect

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 05:34, 10 September 2021 (Protected edit request on 7 September 2021: done). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconRedirect Template‑class
WikiProject iconThis page is within the scope of WikiProject Redirect, a collaborative effort to improve the standard of redirects and their categorization on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Note: This banner should be placed on the talk pages of project, template and category pages that exist and operate to maintain redirects.
This banner is not designed to be placed on the talk pages of most redirects and almost never on the talk pages of mainspace redirects. For more information see the template documentation.
TemplateThis module does not require a rating on Wikipedia's content assessment scale.

Why am I confused?

At WP:VPT §Is it possible to resolve a redirect in template? you wrote:

... [[{{#invoke:redirect|main|WP:AFC}}]] gets you Wikipedia:Articles for creation ...

So I visited Module:Redirect and found this:

---- This module accepts the name of a single page. It determines if the page is a redirect; if so it looks up the page, extracts the target, and returns the target name as text.


So, why, he asks, are there two parameters? In the example you gave both main and WP:AFC. I tried your module with the redirect page from the WT:VPT conversation:

[[{{#invoke:redirect|RNAS_Kirkwall|WP:AFC}}]] → [[Script error: The function "RNAS_Kirkwall" does not exist.]]
[[{{#invoke:redirect|main|RNAS_Kirkwall}}]]Kirkwall Airport

Why are two parameters necessary? And, surely there is a better error message than Script error.

Trappist the monk (talk) 17:12, 18 March 2013 (UTC)[reply]

It occurred to me to also wonder if the first parameter could be empty:
[[{{#invoke:redirect||RNAS_Kirkwall}}]] → [[Script error: The function "" does not exist.]]
Apparently not. So what about meaningless text?
[[{{#invoke:redirect|sdjadrsgjlk|RNAS_Kirkwall}}]] → [[Script error: The function "sdjadrsgjlk" does not exist.]]
Again, apparently not. So what about the name of a real article?
[[{{#invoke:redirect|UP Aerospace|RNAS_Kirkwall}}]] → [[Script error: The function "UP Aerospace" does not exist.]]
Nope. Is "main" some sort of secret word?
Trappist the monk (talk) 17:34, 18 March 2013 (UTC)[reply]
{{#invoke:}} takes two parameters: the first is the module name (redirect in this case), the second the function to use from that module (main in this case, as specified by the line "function p.main(frame)" in the module). So the third parameter given to #invoke is the first parameter given to the function. In that way modules can make more than one functions available.
To get more information on the script error, you have click it. MrBlueSky (talk) 14:40, 19 March 2013 (UTC)[reply]
Thank you. I've learned a bit here.
Trappist the monk (talk) 15:16, 19 March 2013 (UTC)[reply]
Thanks for answering that! I've gotten used to using these module talk pages for anything but talking, and this is the first I noticed the conversation... Wnt (talk) 20:44, 19 March 2013 (UTC)[reply]

Redirect types and categories

I am working on building a module to hold the matrix of the {{redr}} codes and associated categories, and also to have logic that automatically detects the correct codes for a redirect. See Wikipedia:Lua_requests#Redirect_categorisation and especially the especially User:John Vandenberg/AutoCategoriseRedirect where I am doing some initial prototyping. The easiest to automatically detect are WP:Shortcuts and Category:Cross-namespace redirects, and those are the ones I am most interested in automatically detecting. @Wnt:, if you think any of the functionality I am working on would benefit this module, and the current uses, some code sharing needs to be organised (the code could be put in this module, or in a separate module that this modules uses), as the automatic redirect type detection should use the 'Redirect' module to extract the redirect target. John Vandenberg (chat) 00:41, 22 January 2014 (UTC)[reply]

Well, actually at the moment I can't edit the module on account of it being protected (Mr. Stradivarius did say I could get template editor status, but I procrastinated about picking out a more secure password). He actually rewrote a lot of the highest-level code in the module anyway, and should be good to ask. Also, I wonder about -- I don't really know -- how much time it takes to require a routine out of another module. I don't understand how you're going to get your module called from uncategorized redirects, but if you end up tagging a very large number of them, even a tiny delay for opening another module could add up. And, if someone ever goes in and edits the required Module:Redirect, it'll affect all those pages. There's also a little bit of optimization that can be done by combining the two modules: right now, you do an #invoke:Page|namespace and an invoke of this module, each of which make an expensive call to mw.title.new(), and both would have to be adapted if they're to share it. So I'm thinking you might want to just copy the code, as inelegant as that may be. Wnt (talk) 07:53, 22 January 2014 (UTC)[reply]
I'll implement the new module slowly using this module, on only a few pages of each type, so that changes dont have a large impact. If there is a performance issue, I'll switch to calling the relevant functions directly. John Vandenberg (chat) 10:32, 26 January 2014 (UTC)[reply]

Flag to resolve soft redirects and redirects at RfD

When a redirect is listed at RfD, it looks like User:John Vandenberg/testcases/Redirect/1 (as documented poorly at mw:Help:Redirects), which the mediawiki software determines is not a 'redirect', and this module doesnt parse and extract the redirect target. It would be nice if {{RFDnote}} and other functions could ask for the redirect target using this module, knowing that it is currently not an active redirect. Likewise, it would be nice if this module could extract the target from {{soft redirect}}, {{wiktionary redirect}}, etc. I think one 'soft=yes' flag would be sufficient to support any 'semi'-redirect page. I'm happy to put up a code mod in the sandbox if others think this is appropriate. Otherwise I'll write a SoftRedirect Module ;-) John Vandenberg (chat) 09:51, 26 January 2014 (UTC)[reply]

Protected edit request on 15 April 2014

Please make these changes, so that {{#invoke:redirect|main|{{TALKPAGENAME}}}} works right when the page name contains apostrophes or other characters escaped by {{TALKPAGENAME}}. Jackmcbarn (talk) 21:13, 15 April 2014 (UTC)[reply]

DoneMr. Stradivarius ♪ talk ♪ 06:25, 16 April 2014 (UTC)[reply]
@Mr. Stradivarius: This change will re-break this if it goes live. See the last test in Module talk:Redirect/sandbox testcases. (Unrelated: Why does this module have a /testcases and a /sandbox testcases?) Jackmcbarn (talk) 16:10, 17 May 2014 (UTC)[reply]
@Jackmcbarn: I've moved the sandbox test cases to Module:Redirect/testcases. I've also switched to doing the canonicalisation purely with title objects. This makes things easier coding-wise, but it does mean that we have one more expensive function call for each call to the module. Is this likely to cause problems anywhere? — Mr. Stradivarius ♪ talk ♪ 04:55, 18 May 2014 (UTC)[reply]
@Mr. Stradivarius: I don't think that will cause problems. Jackmcbarn (talk) 17:30, 18 May 2014 (UTC)[reply]

Query

@Wnt and Mr. Stradivarius: just wondering if there might be any possibility of a module which would detect a disambiguation page? There is some logic associated with Template:Disambig editintro which will make it display automatically on such a page; I don't know if it can be exploited here. Thanks — Martin (MSGJ · talk) 09:15, 13 January 2016 (UTC)[reply]

@MSGJ: I had this idea back in 2014, but after talking about it on IRC it looks like it wouldn't be feasible. There's a Phabricator ticket about it at phab:T71441. — Mr. Stradivarius ♪ talk ♪ 09:40, 13 January 2016 (UTC)[reply]
Oh well - pity! But paradoxes must be avoided at all costs ;) — Martin (MSGJ · talk) 09:51, 13 January 2016 (UTC)[reply]
I think there's actually a way to do this. I've elaborated on the ticket. Kaldari (talk) 21:18, 31 October 2016 (UTC)[reply]

Protected edit request on 30 March 2017

Sandbox diffs

Edits allow for the fragment to be included when requesting the target of a redirect, but only when the |fulltext= parameter is set, meaning no changes are required to templates that already use the module as-is.

Example:

  • {{#invoke:Redirect|main|MOS:SEASON}}: Wikipedia:Manual of Style/Dates and numbers
  • {{#invoke:Redirect/sandbox|main|MOS:SEASON}}: Wikipedia:Manual of Style/Dates and numbers

  • {{#invoke:Redirect|main|MOS:SEASON|fulltext=}}: Wikipedia:Manual of Style/Dates and numbers
  • {{#invoke:Redirect/sandbox|main|MOS:SEASON|fulltext=}}: Wikipedia:Manual of Style/Dates and numbers

  • {{#invoke:Redirect|main|MOS:SEASON|fulltext=y}}: Wikipedia:Manual of Style/Dates and numbers#Seasons
  • {{#invoke:Redirect/sandbox|main|MOS:SEASON|fulltext=y}}: Wikipedia:Manual of Style/Dates and numbers#Seasons

-- AlexTW 10:03, 30 March 2017 (UTC)[reply]

URL 1 is the "old" part of your sandbox diffs link, and URL 2 is the "new". Do I understand rightly that URL 1 is the current version of the module page, and that you're asking that we copy the content of URL 2 to the module? Nyttend (talk) 00:54, 3 April 2017 (UTC)[reply]
PS, AlexTheWhovian, I meant to ping you in the first edit but forgot. Nyttend (talk) 00:55, 3 April 2017 (UTC)[reply]
@Nyttend: My bad. What I'm looking to be implemented is what is in the sandbox as it stands now. -- AlexTW 00:57, 3 April 2017 (UTC)[reply]
Done. They didn't make me an admin because I understand this kind of coding — as always, any admin should revert me without question if I made some sort of mistake. Nyttend (talk) 01:03, 3 April 2017 (UTC)[reply]
Thank you! Now I can proceed with my related projects. I've tested the code thoroughly, and the edits only add onto the previous version of the code; any article using the code should remain exactly the same as it was. Cheers for that. -- AlexTW 01:04, 3 April 2017 (UTC)[reply]

Protected edit request on 26 June 2017

For Testing SoumyaSahu (talk) 10:43, 26 June 2017 (UTC)[reply]

 Not done Unclear request. If you want to modify test to the module, you may do so at Module:Redirect/sandbox. -- AlexTW 10:50, 26 June 2017 (UTC)[reply]

cross project calls

Is there a way to show if a page in another project is a redirect and find the actual article? --Traveler100 (talk) 11:31, 17 February 2018 (UTC)[reply]

Why parse the page content?

Hi. Why does this module parse the page text to find the redirect target? Why not use Title.redirectTarget instead? I guess Title.redirectTarget wasn't available when this was implemented, but now that it's there, it should be used instead. Qwertyytrewqqwerty (talk) 14:28, 3 March 2018 (UTC)[reply]

Or maybe there's some good reason for it to work like that. AlexTheWhovian, any thoughts on this?
I have a version that uses Title.redirectTarget here: es:Módulo:Redirect es:Módulo:Redirección (no testcases, though). Qwertyytrewqqwerty (talk) 10:04, 9 March 2018 (UTC).[reply]
I've sandboxed it Galobtter (pingó mió) 11:41, 31 March 2018 (UTC)[reply]
Somebody sumbit an edit request!. {{3x|p}}ery (talk) 00:34, 15 May 2018 (UTC)[reply]

Expensive call?

Could someone add to the documentation that this module call is expensive (or not expensive)? - 15:58, 21 March 2018 (UTC)

redirected files

T193162 {{#invoke:redirect|isRedirect|File:IMAGE.jpg}} gives "" (blank), despite the fact that File:IMAGE.jpg is a redirect to File:IMAGE (Explorer 78).jpg. I created phabricator:T193162 about this issue, but wanted to alert you that this module is also affected. --Jarekt (talk) 13:15, 26 April 2018 (UTC)[reply]

Jarekt, do you think this could be related to another strange behaviour (possibly related to isRedirect) causing spurious transclusions being reported in various places? See here: User talk:Paine Ellsworth#Interesting transclusion effect - any idea?
Thanks and greetings. --Matthiaspaul (talk) 07:27, 30 July 2018 (UTC)[reply]

Template-protected edit request on 11 February 2019

Kindly add me to the list. User: Shevonsilva Shevonsilva (talk) 22:48, 11 February 2019 (UTC)[reply]

 Not done User:Shevonsilva, this is the module, not the Wikiproject page, the module do not contain any user name list. If you would like to add your name to the project, you need to go to Wikipedia:WikiProject_Redirect#Participants and add your name there. -- VulpesVulpes825 (Talk) 00:02, 12 February 2019 (UTC)[reply]

Module redirection

There is not a warning system in ¨Wikipedia or WikiMedia to say: this module exists with other name (ie. taken the information from Wikidata), as Wikimedia Commons does when you try to upload an existing image. So, what to do when creating a module, when one thinks it did not exist (and exist with other translated name)?. Can be used temporally an {{#invoke:}} to the other module?. --BoldLuis (talk) 20:01, 14 May 2020 (UTC)[reply]

Protected edit request on 7 September 2021

Please apply these changes, originally written by User:Galobtter. This will make it so the redirect target is just taken from the table returned by mw.title.new using the redirectTarget property instead of having to find it in the wikitext of the redirect, saving an expensive parser function call. These changes cause a test case to fail, but that can be disregarded because they make it (and a few more) obsolete anyway. – Rummskartoffel 11:58, 7 September 2021 (UTC)[reply]

 Done. @Rummskartoffel: is it the testContentPercentInsideAmpersandCanonicalisation test you were referring to above? — Martin (MSGJ · talk) 05:34, 10 September 2021 (UTC)[reply]