Template talk:Pagetype
To help centralize discussions and keep related topics together, Module talk:Pagetype redirects here. |
Template:Pagetype is permanently protected from editing because it is a heavily used or highly visible template. 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. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
Text and/or other creative content from this version of Template:Pagetype was copied or moved into incubator:Template:Wp/nod/pagetype with this edit. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted as long as the latter page exists. |
Books
edit{{editprotected}}
This should be updated to account for |class=book. Headbomb {ταλκκοντριβς – WP Physics} 06:15, 11 December 2009 (UTC)
- I'm not exactly sure what the behavior should be. Somewhat important when changing a template that is used 2.7 million times. —TheDJ (talk • contribs) 12:45, 11 December 2009 (UTC)
- I don't think "books" is a proper classification here. Either way, these changes need to be made in a sandbox like Template:pagetype/sandbox to avoid breaking things. --MZMcBride (talk) 18:44, 11 December 2009 (UTC)
Needed
editShould |class=needed
be produce "page" or "article"? — Martin (MSGJ · talk) 07:27, 29 April 2010 (UTC)
- I thought we didn't support Needed-Class anymore. Happy‑melon 15:24, 29 April 2010 (UTC)
- But what about all the subcategories of Category:Needed-Class articles? — Martin (MSGJ · talk) 16:07, 29 April 2010 (UTC)
- And the subcategories of Current-Class articles, or Merge-Class articles, or any of the other custom classes?? Those classes which we said should be available for projects to use if they wish, but for which we should not bloat banner code for all projects. There are 74 Needed-Class categories, 63 of which are empty. I don't agree that we should make any move to better integrate these niche classes when that disadvantages 1,600 projects for the sake of less than a dozen. Happy‑melon 21:31, 29 April 2010 (UTC)
- Fair enough. I hadn't noticed that so many of them were empty. — Martin (MSGJ · talk) 10:32, 30 April 2010 (UTC)
- And the subcategories of Current-Class articles, or Merge-Class articles, or any of the other custom classes?? Those classes which we said should be available for projects to use if they wish, but for which we should not bloat banner code for all projects. There are 74 Needed-Class categories, 63 of which are empty. I don't agree that we should make any move to better integrate these niche classes when that disadvantages 1,600 projects for the sake of less than a dozen. Happy‑melon 21:31, 29 April 2010 (UTC)
- But what about all the subcategories of Category:Needed-Class articles? — Martin (MSGJ · talk) 16:07, 29 April 2010 (UTC)
talkspace=yes
editI think a talkspace=yes, similar to subjectspace=yes, would be useful to have as an optional parameter for this template. It should, if on a talk page, return "talk page" and otherwise return the default value. This would be useful for templates like {{Last edited by}} to be more accurate or {{In use}} so we can get rid of the switch function there. --The Evil IP address (talk) 18:08, 6 June 2010 (UTC)
- Sorry I can't understand what you mean. Can you describe the behaviour of the template with this new parameter? — Martin (MSGJ · talk) 18:46, 6 June 2010 (UTC)
- Currently, on a talk page, this template shows the subject namespace, for example on an article talk page, it shows "article", on a template talk page it shows "template", and so on. However, there are situations in which it would be good to return "talk page" instead, for example within {{Last edited by}}. I'd like to add this template to {{Db-meta}} in the next time (which already uses a similar hardcoded function of this template), but since db templates are also used on talk pages, showing "article" or "template" wouldn't make sense there. --The Evil IP address (talk) 13:10, 9 June 2010 (UTC)
- Ah now I understand. I would be open to such an addition if it can be coded cleanly without affecting the performance for the majority of uses (as this is a very widely used template!) Question: could you not just use {{NAMESPACE}} page in your case? — Martin (MSGJ · talk) 15:36, 9 June 2010 (UTC)
- Fixed by using Template:pp-meta/pagetype instead. Prodego talk 23:59, 12 January 2011 (UTC)
- Ah now I understand. I would be open to such an addition if it can be coded cleanly without affecting the performance for the majority of uses (as this is a very widely used template!) Question: could you not just use {{NAMESPACE}} page in your case? — Martin (MSGJ · talk) 15:36, 9 June 2010 (UTC)
- Currently, on a talk page, this template shows the subject namespace, for example on an article talk page, it shows "article", on a template talk page it shows "template", and so on. However, there are situations in which it would be good to return "talk page" instead, for example within {{Last edited by}}. I'd like to add this template to {{Db-meta}} in the next time (which already uses a similar hardcoded function of this template), but since db templates are also used on talk pages, showing "article" or "template" wouldn't make sense there. --The Evil IP address (talk) 13:10, 9 June 2010 (UTC)
Misleading documentation
editAccording to the documentation there's a parameter "subjectspace - If set to yes then subjectspace pages will be treated the same as talkspace pages."
Without subjectspace: {{pagetype|page=Category:X1}} and {{pagetype|page=Category talk:X1}} produce "category" and "category".
With subjectspace: {{pagetype|page=Category:X1|subjectspace=yes}} and {{pagetype|page=Category talk:X1|subjectspace=yes}} produce "category" and "category".
There's an unnamed parameter, "class", but that's "optional" and the documentation suggests that it shouldn't affect the result in this case. Is the intention to require page name (which includes namespace) and namespace specified as separate parameters? Peter James (talk) 00:01, 22 September 2013 (UTC)
- I've updated the docs to match what the template does. -- WOSlinker (talk) 00:15, 22 September 2013 (UTC)
- It's still misleading. "This template is used to identify what kind of page it or its subject page is." - but when used with a page name, it returns "Article" for a template and "Template" for a template talk page. Is there something similar to Template:Pp-meta/pagetype (mentioned above) but allowing a parameter for page name? Peter James (talk) 08:02, 22 September 2013 (UTC)
- This template was designed for use by WikiProject banners so it was mainly just tested on talk pages and currently doesn't do very well with non-talk pages. I'll have alook at doing something better in the sandbox soon. -- WOSlinker (talk) 08:33, 22 September 2013 (UTC)
- I found it in use in Template:Edit protected and Template:Edit semi-protected, where parameter is needed because of a change to MediaWiki:Protectedpagetext. I've had to use TALKPAGENAME in those templates, which isn't ideal but produces the correct result (except in the unlikely event of a request for an edit to a redirected talk page). It may produce incorrect results if this template is changed, although it only affects the message and not the template's function. If improving or replacing this template, it may also be possible to use Module:Redirect to determine whether a page is a redirect, although it currently fails where "#REDIRECT:" (instead of just "#REDIRECT" is used. Peter James (talk) 10:12, 22 September 2013 (UTC)
- Right, I've made some changes in the sandbox and now {{pagetype/sandbox|page=Category:X1}} and {{pagetype/sandbox|page=Category talk:X1}} produce "category" and "category". I've also removed the subjectspace option from the sandbox since it's not needed with the changes that I've made. Can you give it a test yourself & if you are happy, we can make it live. -- WOSlinker (talk) 13:30, 22 September 2013 (UTC)
- It's an improvement for pages not in talk or article space, and does what the "output" section of the documentation says, with the exception of "portal" or "project" class in subjectspace - is that needed? Peter James (talk) 15:08, 22 September 2013 (UTC)
- I think that's fine. I've updated the template and the docs. -- WOSlinker (talk) 16:07, 22 September 2013 (UTC)
- It's an improvement for pages not in talk or article space, and does what the "output" section of the documentation says, with the exception of "portal" or "project" class in subjectspace - is that needed? Peter James (talk) 15:08, 22 September 2013 (UTC)
- Right, I've made some changes in the sandbox and now {{pagetype/sandbox|page=Category:X1}} and {{pagetype/sandbox|page=Category talk:X1}} produce "category" and "category". I've also removed the subjectspace option from the sandbox since it's not needed with the changes that I've made. Can you give it a test yourself & if you are happy, we can make it live. -- WOSlinker (talk) 13:30, 22 September 2013 (UTC)
Module:Pagetype
editI've created a Lua implementation of this template at Module:Pagetype. It's much more customisable than this template, and can be used to create other pagetype-like templates with different namespace configurations and custom text values. Have a look at the module documentation for details. The default settings are almost the same as this template, with one important difference - redirects are now detected and displayed as "redirect", no matter what namespace they are in. If this is undesirable I can change it, but it won't be easy to change the redirect detection on a per-namespace basis, due to the way the module hooks into Module:Namespace detect. Please have a look at the module, test it a bit, and see if there are any bugs, or anything you would like to change. You might also want to take a look at the test cases (results). If everything is ok, I plan to update {{pagetype}} with this module some time this week. — Mr. Stradivarius ♪ talk ♪ 14:07, 4 November 2013 (UTC)
- Great! I notice that {{db-meta}} uses the following construction several times:
{{talk other|talk page|{{pagetype|subjectspace=yes}}}}
- Does your version make this simpler to do? — Martin (MSGJ · talk) 11:23, 7 November 2013 (UTC)
- Seems as though
{{#invoke:pagetype|main|talk=y}}
would work here as a shorter replacement. -- WOSlinker (talk) 12:00, 7 November 2013 (UTC)- Yes, that's right - you could also use
{{#invoke:pagetype|main|defaultns=all}}
, depending on how many namespaces you want to include by default. I also wasn't aware of the|subjectspace=
parameter until now, as it was removed with this edit, so adding|subjectspace=yes
to the module won't have any effect. — Mr. Stradivarius ♪ talk ♪ 14:13, 7 November 2013 (UTC)- Ok, I've made the switch to the new module. Let me know if you spot any issues. — Mr. Stradivarius ♪ talk ♪ 07:50, 9 November 2013 (UTC)
- Yes, that's right - you could also use
- Seems as though
Misleading message about redirect
editIf you put {{Edit protected|MediaWiki talk:Spam-blacklist/log}}
on MediaWiki talk:Spam-blacklist, the box begins with "It is requested that an edit be made to the fully protected redirect at MediaWiki talk:Spam-blacklist/log.". Why "redirect", when MediaWiki talk:Spam-blacklist/log isn't? See this permalink. --Redrose64 (talk) 18:54, 3 April 2014 (UTC)
- @Mr. Stradivarius: The issue is that when p._main{page='MediaWiki talk:Spam-blacklist/log'} is called, checkRedirects instead checks to see if MediaWiki:Spam-blacklist/log is a redirect (lines 208-211). I'm not sure what the logic behind doing that that way is. Thoughts? Jackmcbarn (talk) 19:16, 3 April 2014 (UTC)
- Yep, that's a bug in the module. It should use the current page rather than the subject page if talk pages are allowed, but at the moment it only checks args.talk, not args.defaultns. I'll have a think about how best to fix this. (Also, your ping didn't work - not sure why.) — Mr. Stradivarius ♪ talk ♪ 04:12, 4 April 2014 (UTC)
- Now fixed. I also uncovered a nasty bug that was introduced by the recent changes to Module:Namespace detect - this module was trying to use the # operator with the mappings table, which didn't work after it was switched to load using mw.loadData. I also split out the config data to Module:Pagetype/config, loaded using mw.loadData. And I made some beautification fixes too. — Mr. Stradivarius ♪ talk ♪ 06:01, 4 April 2014 (UTC)
- I didn't get a ping either. It might be because it was a page creation? --Redrose64 (talk) 10:18, 4 April 2014 (UTC)
- @Mr. Stradivarius: Broken in the opposite way now. [1] says talk page instead of module. Jackmcbarn (talk) 16:05, 5 April 2014 (UTC)
- Bleh. That was a bug I introduced to Module:Namespace detect this morning trying to fix an unrelated issue. That's now fixed as well. And with that, I think I shall call it a night. If you notice other similar problems, purging should fix it. — Mr. Stradivarius ♪ talk ♪ 17:13, 5 April 2014 (UTC)
- @Mr. Stradivarius: Broken in the opposite way now. [1] says talk page instead of module. Jackmcbarn (talk) 16:05, 5 April 2014 (UTC)
- Yep, that's a bug in the module. It should use the current page rather than the subject page if talk pages are allowed, but at the moment it only checks args.talk, not args.defaultns. I'll have a think about how best to fix this. (Also, your ping didn't work - not sure why.) — Mr. Stradivarius ♪ talk ♪ 04:12, 4 April 2014 (UTC)
Drafts
editI don't think this module identifies pages in the draft namespace. Please could this be added? — Martin (MSGJ · talk) 11:40, 3 October 2014 (UTC)
- You could either use {{pagetype|draft=true}} or you could edit the cfg.defaultNamespaces section of Module:Pagetype/config. -- WOSlinker (talk) 11:56, 3 October 2014 (UTC)
- @MSGJ: Drafts are detected fine - they are one of the extended namespaces. See Module:Pagetype#Default namespace sets for a quick look at what is in what set. And if you think drafts should be in the default set instead of just the extended set, we can make the change in the module config, as WOSlinker said. (We should probably get consensus for that first, though.) — Mr. Stradivarius ♪ talk ♪ 13:13, 3 October 2014 (UTC)
- Yes well, perhaps "draft" should be in that set.
Also I'm surprised that "file" is not there.— Martin (MSGJ · talk) 13:51, 3 October 2014 (UTC) - Hmm I see "file" is there, but not in the "media" row so I'm a bit confused by that. — Martin (MSGJ · talk) 13:53, 3 October 2014 (UTC)
- @MSGJ: That's because when you click a link to a media namespace page, you're not going to a wiki page, but you're viewing the file directly. For example: Media:Example.svg. — Mr. Stradivarius ♪ talk ♪ 14:00, 3 October 2014 (UTC)
- Interesting, I didn't know that! In the meantime I've used
|draft=yes
on Template:Importance mask so it works as intended. Cheers all — Martin (MSGJ · talk) 11:29, 4 October 2014 (UTC)
- Interesting, I didn't know that! In the meantime I've used
- @MSGJ: That's because when you click a link to a media namespace page, you're not going to a wiki page, but you're viewing the file directly. For example: Media:Example.svg. — Mr. Stradivarius ♪ talk ♪ 14:00, 3 October 2014 (UTC)
- Yes well, perhaps "draft" should be in that set.
- @MSGJ: Drafts are detected fine - they are one of the extended namespaces. See Module:Pagetype#Default namespace sets for a quick look at what is in what set. And if you think drafts should be in the default set instead of just the extended set, we can make the change in the module config, as WOSlinker said. (We should probably get consensus for that first, though.) — Mr. Stradivarius ♪ talk ♪ 13:13, 3 October 2014 (UTC)
Protected edit request on 28 September 2015
editThis edit request to Module:Pagetype has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Add the Gadget and Gadget definition namespaces and make the page type the same name, but with a lowercase "G". GeoffreyT2000 (talk) 02:50, 28 September 2015 (UTC)
Set index articles
edit@Mr. Stradivarius: Is there any way for the module to distinguish between disambiguation pages and set index articles? PC78 (talk) 00:06, 5 July 2016 (UTC)
- I asked about disambiguation pages somewhere before and was told that it is impossible ;( — Martin (MSGJ · talk) 11:28, 12 July 2016 (UTC)
- @PC78: see Module talk:Redirect#Query — Martin (MSGJ · talk) 11:32, 12 July 2016 (UTC)
- Hmm. The doc refers to disambiguation pages at Module:Pagetype/doc#Main namespace classes. Does this not do what I think it does? PC78 (talk) 17:02, 12 July 2016 (UTC)
- You have to tell the module that it is a disambiguation page using the class parameter. It won't detect it automatically, which I think it what you were asking about. — Martin (MSGJ · talk) 19:25, 12 July 2016 (UTC)
- Ah-ha. How does the Metadata gadget do it then, is that not something that can be applied to a template? PC78 (talk) 06:49, 13 July 2016 (UTC)
- The gadget also uses the class rating from the article's talk page, I believe! — Martin (MSGJ · talk) 09:36, 20 April 2023 (UTC)
- Ah-ha. How does the Metadata gadget do it then, is that not something that can be applied to a template? PC78 (talk) 06:49, 13 July 2016 (UTC)
- You have to tell the module that it is a disambiguation page using the class parameter. It won't detect it automatically, which I think it what you were asking about. — Martin (MSGJ · talk) 19:25, 12 July 2016 (UTC)
- Hmm. The doc refers to disambiguation pages at Module:Pagetype/doc#Main namespace classes. Does this not do what I think it does? PC78 (talk) 17:02, 12 July 2016 (UTC)
Detecting disambiguation pages
editWould it be possible to detect disambiguation pages from this module? Disambiguation pages have the page property "disambiguation". Can you retrieve page properties from Lua modules? Kaldari (talk) 20:44, 31 October 2016 (UTC)
- Please see Module talk:Redirect#Query! — Martin (MSGJ · talk) 20:54, 31 October 2016 (UTC)
- Thanks for the pointer. After looking at the Phab ticket and the Scribunto code, I think I actually know how this could be implemented. Kaldari (talk) 21:19, 31 October 2016 (UTC)
cross project calls
editShould this work across wikiprojects? For example
- {{#invoke:pagetype|main|page=Frankfurt}} gives: article
- {{#invoke:pagetype|main|page=Wikipedia:Frankfurt}} gives: page
- {{#invoke:pagetype|main|page=Wikivoyage:Frankfurt}} gives: page
- {{#invoke:pagetype|main|page=Voy:Frankfurt}} gives: page
- {{#invoke:pagetype|main|page=Frankfurt/Main}} gives: redirect
- {{#invoke:pagetype|main|page=Wikipedia:Frankfurt/Main}} gives: page
- {{#invoke:pagetype|main|page=W:Frankfurt/Main}} gives: redirect
- {{#invoke:pagetype|main|page=Wikipedia:Frankfurt/Main123}} gives: page
- {{#invoke:pagetype|main|page=Wikivoyage:Frankfurt/Main}} gives: page
- {{#invoke:pagetype|main|page=FRA}} gives: page
- {{#invoke:pagetype|main|page=Wikipedia:FRA}} gives: redirect
- {{#invoke:pagetype|main|page=W:FRA}} gives: page
- {{#invoke:pagetype|main|page=Wikivoyage:FRA}} gives: page
- {{#invoke:pagetype|main|page=Voy:FRA}} gives: page
Does not appear to be giving correct results, or am I misunderstanding the syntax? --Traveler100 (talk) 12:21, 15 February 2018 (UTC)
- I don't believe this is possible and/or desirable — Martin (MSGJ · talk) 09:46, 20 April 2023 (UTC)
Plurals
editFollowing a request at Wikipedia talk:Short description #Category fix needed, which complained that the {{Short description}} naively pluralises 'category' as 'categoriescategorys', I looked for a fix. As the template calls Template:Pagetype in three places, it seemed hugely inefficient to use logic to test for irregular plurals at each call, so I've implemented a boolean |plural=
parameter in Module:Pagetype/sandbox. That makes use of a couple of extra variables that I've added to Module:Pagetype/config/sandbox (to allow localisation for other Wikis). I've set each respective sandbox to call the relevant sandbox. So:
{{pagetype/sandbox}}
→ template{{pagetype/sandbox |plural=y}}
→ templates{{pagetype/sandbox |plural=n |page=Category:CS1 maint: archived copy as title}}
→ category{{pagetype/sandbox |plural=y |page=Category:CS1 maint: archived copy as title}}
→ categories
It seems to work without problem on each type of page, including redirects where I've previewed the above code. It fails the same four testcases at Module talk:Pagetype/testcases that were failing before (pages that are now redirects).
As I'm not familiar with the uses of the less common parameters (although there should be no interaction as I've coded the changes at the output of the main function), I'm flagging this up for review and to seek consensus for the changes to be made. --RexxS (talk) 23:16, 24 May 2020 (UTC)
Sorry, I should have pinged Mr. Stradivarius as the author of the module. --RexxS (talk) 23:19, 24 May 2020 (UTC)
- I support this change, with a minor note that for posterity, I think your original description of the error should read
naively pluralises 'category' as 'categorys'
(note the misspelled last word). I was going to strike it out for you, but I might be misunderstanding the situation entirely. – Jonesey95 (talk) 23:40, 24 May 2020 (UTC)- Thanks for spotting that, Jonesey95 – my internal spell-checker clearly took over (either that or my senility is progressing faster than I thought). Cheers --RexxS (talk) 23:50, 24 May 2020 (UTC)
- @RexxS: thanks for coding this, and please do implement — Martin (MSGJ · talk) 15:25, 9 June 2020 (UTC)
- Apologies, I did that last week, but forgot to update this thread. This template now accepts the
|plural=
parameter:{{pagetype}}
→ template{{pagetype |plural=y}}
→ templates{{pagetype |plural=n |page=Category:CS1 maint: archived copy as title}}
→ category{{pagetype |plural=y |page=Category:CS1 maint: archived copy as title}}
→ categories
- I've updated the documentation at Template:Pagetype/doc #Plurals. --RexxS (talk) 16:07, 9 June 2020 (UTC)
- Apologies, I did that last week, but forgot to update this thread. This template now accepts the
- @RexxS: thanks for coding this, and please do implement — Martin (MSGJ · talk) 15:25, 9 June 2020 (UTC)
- Thanks for spotting that, Jonesey95 – my internal spell-checker clearly took over (either that or my senility is progressing faster than I thought). Cheers --RexxS (talk) 23:50, 24 May 2020 (UTC)
Protected edit request on 18 June 2020
editThis edit request to Module:Pagetype has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Implement the change I've made at Module:Pagetype/sandbox; specifically, the addition of a |caps=
parameter, that capitalises the first letter of the output. The change is very simple; below line 209, insert the following:
if yesno(args.caps, false) then
pagetype = mw.ustring.upper(mw.ustring.sub(pagetype, 1, 1)) ..
mw.ustring.sub(pagetype, 2)
end
The indentation on the output above is... interesting... but the correct indentation is used in the wikitext.
You can see this working in the test cases, where I've written specific tests for it; it plays nicely with the |plural=
parameter, as you'd expect. It is worthy of note that I've had to separately fix some of the other testcases, as the pages that they depended on have changed since the last time the testcases were used.
Please let me know once this is sorted so I can update the documentation for the new parameter.
Thanks! Naypta ☺ | ✉ talk page | 18:40, 18 June 2020 (UTC) Naypta ☺ | ✉ talk page | 18:40, 18 June 2020 (UTC)
- The code works fine, but is there a use case for it? As an aside,
:gsub("^(%l)", string.upper)
is a compact way of doing ucfirst (that's %'lower-case-L' in the pattern). --RexxS (talk) 20:27, 18 June 2020 (UTC)- @RexxS: The intended use case would be to have templates that either categorise pages, or link to categories of pages, shown correctly with the capitalisation of the first letter of the category. In the first case, which was actually what prompted me to propose this change, there's not much practical difference, because MediaWiki doesn't care about first letter capitalisation, and categories are processed through it. In the second, however, there's a visible difference for people looking at the link. It's no big deal, but it's a nice thing to have, and for the few lines of code it takes to support it, I figured why not Thanks for the tip about ucfirst - I'd not thought of just using a gsub, good shout! Naypta ☺ | ✉ talk page | 21:06, 18 June 2020 (UTC)
- @Naypta: I've implemented your change and tidied the odd indent. Please check it over and update the documentation when you get a chance. Cheers. --RexxS (talk) 21:28, 18 June 2020 (UTC)
- @RexxS: Done and dusted - cheers! I've also added TemplateData for
|plural=
, and tidied up the documentation on the template to use examples of template code rather than of module code. Naypta ☺ | ✉ talk page | 21:37, 18 June 2020 (UTC)
- @RexxS: Done and dusted - cheers! I've also added TemplateData for
- @Naypta: I've implemented your change and tidied the odd indent. Please check it over and update the documentation when you get a chance. Cheers. --RexxS (talk) 21:28, 18 June 2020 (UTC)
- @RexxS: The intended use case would be to have templates that either categorise pages, or link to categories of pages, shown correctly with the capitalisation of the first letter of the category. In the first case, which was actually what prompted me to propose this change, there's not much practical difference, because MediaWiki doesn't care about first letter capitalisation, and categories are processed through it. In the second, however, there's a visible difference for people looking at the link. It's no big deal, but it's a nice thing to have, and for the few lines of code it takes to support it, I figured why not Thanks for the tip about ucfirst - I'd not thought of just using a gsub, good shout! Naypta ☺ | ✉ talk page | 21:06, 18 June 2020 (UTC)
Question regarding the use of the dab parameter
editI'm not sure I understand how the |dab=
parameter works. I have a usecase that I want to check if a page is an actual article or a dab or redirect. If I understand correctly from the docs I should do:
{{Pagetype|page=AC|dab}}
, which produces: page{{Pagetype|page=Air conditioning|dab}}
, which produces: article
The first is a dab while the second is an article. What am I doing wrong? --Gonnym (talk) 10:42, 2 July 2020 (UTC)
- I don't think there is any way to check if a page is a disambig automatically, so what you are doing above is passing in the class value and because the class value you've passed is "dab", it outputs "page". If you have passed "start" for example then it would have output "article".
{{Pagetype|page=AC|start}}
, which produces: page
- You can see what's possible against the Title object in the LUA reference manual and you'll see that there are items to check for redirects but nothing for disambig. Also see phabricator T71441.-- WOSlinker (talk) 13:42, 2 July 2020 (UTC)
- Yeah I know there is no direct access, but I thought there was some backend manipulation the page content. So I'm not sure what the point is of the dab class. If I already know what the page type is, why would I send the page type, or even use this template in the first place? I feel like I'm missing something here. --Gonnym (talk) 13:51, 2 July 2020 (UTC)
- A couple of hacks come to mind that could determine whether a page is a dab page:
- Using a call to a Scribunto module that fetches the content of the page,
titleobject.getcontent()
, and then looks for the {{disambiguation}} template in it. Heavy and expensive. - If you're checking from Wikidata from an entity, use the fact that
titleobject.redirectTarget
returns false if the page is not a redirect; andmw.wikibase.getSitelink(qid)
returns nil if the page has no Wikidata sitelink. If an article page has no Wikidata sitelink and is not a redirect, it is almost certainly a dab.
- Using a call to a Scribunto module that fetches the content of the page,
- There are possibly others, but I'm not aware of any 100% guaranteed way that doesn't depend on some assumptions. --RexxS (talk) 15:49, 2 July 2020 (UTC)
- @RexxS:, thanks. I've been looking into the page:content() before I came here. Can you explain to me what's the purpose of the dab parameter? --Gonnym (talk) 16:04, 2 July 2020 (UTC)
- There's more than just the disambiguation template to look for, there's some of the following templates that are also used for that purpose as well. -- WOSlinker (talk) 16:40, 2 July 2020 (UTC)
- @RexxS:, thanks. I've been looking into the page:content() before I came here. Can you explain to me what's the purpose of the dab parameter? --Gonnym (talk) 16:04, 2 July 2020 (UTC)
- The main purpose of the Pagetype template is to be used on the project banners to show either "article" or "page" in the banner text. -- WOSlinker (talk) 16:33, 2 July 2020 (UTC)
- @Gonnym: As an example, if this template is used inside a WikiProject template, it can read the
|class=
parameter (passed into the WikiProject template) like this:{{pagetype|{{{class|}}} }}
and then might be used to create a category name that the article should belong to, given that if the class is given as dab or n/a, the template will then return "page" instead of "article". There is the ability to specify custom text for either dab or n/a, depending on the naming convention required for the category name. Does that make sense? --RexxS (talk) 20:42, 2 July 2020 (UTC)- Yes, thanks! --Gonnym (talk) 22:25, 2 July 2020 (UTC)
- @Gonnym: As an example, if this template is used inside a WikiProject template, it can read the
- A couple of hacks come to mind that could determine whether a page is a dab page:
- Yeah I know there is no direct access, but I thought there was some backend manipulation the page content. So I'm not sure what the point is of the dab class. If I already know what the page type is, why would I send the page type, or even use this template in the first place? I feel like I'm missing something here. --Gonnym (talk) 13:51, 2 July 2020 (UTC)
Erroneous entries in WhatLinksHere
editUsing this template on a file talk page causes Special:WhatLinksHere for the file page to report the talk page linking to the file page. If this is fixable, please do. See also Template talk:WPBannerMeta#Protected edit request on 29 July 2021. — Alexis Jazz (talk or ping me) 11:36, 29 July 2021 (UTC)
Protected edit request on 2 May 2022
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Change page's main title Sterling Entertainment Group to United American Video and lock the page from further editing. The information on this page is wildly inaccurate and most of it has now been edited for accuracy except for the main title.
United American Video was never Sterling Entertainment Group. I should know I was a founder from 1984 to 2005. Jpettus1 (talk) 16:29, 2 May 2022 (UTC)
- Not done this has nothing to do with editing Template:Pagetype; try the talk page attached to whichever article you want to change. — xaosflux Talk 18:31, 2 May 2022 (UTC)
I propose using Module:Disambiguation to automatically detect disambiguation pages, as currently used on Module:Class mask — Martin (MSGJ · talk) 09:50, 20 April 2023 (UTC)
- @Mr. Stradivarius: any chance you could look at this, because I think you wrote this module initialy? — Martin (MSGJ · talk) 10:21, 10 May 2023 (UTC)
- @Mr. Stradivarius: if you do have time to look at this module, it would be appreciated. It does have a significant effect because importance is not being correctly autoclassified as NA on disambiguation talk pages. Thanks — Martin (MSGJ · talk) 09:47, 18 May 2023 (UTC)
- Time is one thing I don't have the luxury of right now... but perhaps I can take a look at some point in the next few weeks. — Mr. Stradivarius ♪ talk ♪ 00:25, 19 May 2023 (UTC)
- @Mr. Stradivarius just a little reminder if you have time to look at this :) Would it also be possible for
|defaultns=extended
to produce "disambiguation page" in this case? Thank you. — Martin (MSGJ · talk) 05:10, 19 August 2023 (UTC)- @MSGJ: I have implemented disambiguation page detection at Module:Pagetype/sandbox. At the moment, this still outputs the default "page" for disambiguation pages. Disambiguation detection works like redirect detection - it is on by default, and is checked before looking at
|defaultns=
or explicit namespace arguments. This means that if we are going to change the module to produce "disambiguation page" for disambiguation pages, with the current implementation this would be independent of the value of|defaultns=
. (It can be done by editing thecfg.dabDefault
value in Module:Pagetype/config/sandbox.)Using "disambiguation page" could be a breaking change for some users, as previously disambiguation pages specified by the first positional parameter have been output as "page". Before changing it, we should probably check to see whether anything is likely to break, and have a wider discussion. In the meantime, you can always change it on a per-template basis by using
|dab=disambiguation page
.My edits to the sandbox have also removed the dependency on Module:Namespace detect, and I also changed Module:Pagetype/testcases to use Module:Mock title so that the test cases won't break if anyone edits any pages mentioned in them. Let me know if you spot any issues with any of this, and if not I'll go ahead and deploy the sandbox version to the main module. Best — Mr. Stradivarius ♪ talk ♪ 07:34, 27 August 2023 (UTC)
- I have gone ahead and deployed the changes to the main module. Please let me know if you spot any issues. Best — Mr. Stradivarius ♪ talk ♪ 13:39, 28 August 2023 (UTC)
- Thanks very much. I'll test it very soon when I get some time. I can use
|dab=disambguation
for now but it would be great if defaultns could be used later, if that is possible — Martin (MSGJ · talk) 20:56, 28 August 2023 (UTC)- @MSGJ: I think changing the default would break too many things. Changing to automatic disambiguation page detection has already broken the categories used by Template:Short description, and it is difficult to tell what else might break by changing the default wording from "page" to "disambiguation page". — Mr. Stradivarius ♪ talk ♪ 13:19, 29 August 2023 (UTC)
- @Mr. Stradivarius and MSGJ: The WikiProject classification for some disambiguation pages such as Dragon Quest Heroes moved from being "NA-importance" by default to "Unknown-importance" as of today; since no change was made to Wikiproject banner shell, I think that this change may have affected that template/module. In looking at what moved and what didn't, it appears that "set index articles" are now no longer "NA" by default, while "normal" disambiguation articles are still handled correctly. I'm presuming that the fix needs to be applied to Wikiproject banner shell, not here, but replying here since there was an active discussion. --PresN 02:21, 30 August 2023 (UTC)
- @PresN: I tracked the problem down to Module:WikiProject banner. It uses Module:Pagetype here, and then compares the result to the string "article" here. This should probably be changed to a namespace check. — Mr. Stradivarius ♪ talk ♪ 02:55, 30 August 2023 (UTC)
- @Mr. Stradivarius: I think it's actually that Module:Disambiguation only looks for disambiguation templates, but set index pages have set index templates, so they don't get counted by the module as a disambiguation page, so Module:Pagetype is saying they're "article". Either Module:Disambiguation should treat those like disambig pages, or else Module:Pagetype should call a Module:Set index with its own regex patterns to handle set index pages. --PresN 11:48, 30 August 2023 (UTC)
- @PresN: Hm, you are right:
{{pagetype|page=Dragon Quest Heroes}}
produces "article". This means that the recent change to Module:Pagetype won't have affected it (unless it was passing "dab" as the first positional parameter, which not many pages do). So there must be another reason for the change from "NA-importance" to "Unknown-importance". By the way, I don't think that set index articles not being detected as disambiguation pages by Module:Disambiguation is an error. From WP:SETINDEX:A set index article (SIA) is a list article about a set of items of a specific type that also share the same (or similar) name
(italics mine). Also, there's an entire section WP:SETNOTDAB explaining that set index articles are not disambiguation pages. — Mr. Stradivarius ♪ talk ♪ 13:26, 30 August 2023 (UTC)- @Mr. Stradivarius: Hmm. Given the definition and examples at that page (e.g. List of peaks named Signal), I see the argument for pagetype treating them as "article" rather than "disambiguation". I also don't think the pages I was looking at are really SIAs by that definition, but should be disambiguation pages. I'll adjust in that direction, and we can leave pagetype as it is. Still not sure what caused banner shell to stop treating them as disambiguation (I don't see anything in the code change that would cause it), but if its more correct this way then that's fine. --PresN 13:52, 30 August 2023 (UTC)
- I must admit that the definition of set index articles confuses me, but the "article" in its name makes it clear that they are articles so I don't there is an error here. I also don't see how the recent change could have affected this — Martin (MSGJ · talk) 20:30, 30 August 2023 (UTC)
- I'm still confused how it did, but there were some SIAs where the talk page template said "|class=Disambiguation" with no importance listed, and yesterday they moved from defaulting as NA-importance to being Unknown-importance. It was consistent on the 1.0 Bot assessment logs. It appears that the current state of things is the correct and intended way, and whatever was treating SIAs as disambiguation pages instead of lists was wrong, so nothing further to do here. --PresN 21:41, 30 August 2023 (UTC)
- I must admit that the definition of set index articles confuses me, but the "article" in its name makes it clear that they are articles so I don't there is an error here. I also don't see how the recent change could have affected this — Martin (MSGJ · talk) 20:30, 30 August 2023 (UTC)
- @Mr. Stradivarius: Hmm. Given the definition and examples at that page (e.g. List of peaks named Signal), I see the argument for pagetype treating them as "article" rather than "disambiguation". I also don't think the pages I was looking at are really SIAs by that definition, but should be disambiguation pages. I'll adjust in that direction, and we can leave pagetype as it is. Still not sure what caused banner shell to stop treating them as disambiguation (I don't see anything in the code change that would cause it), but if its more correct this way then that's fine. --PresN 13:52, 30 August 2023 (UTC)
- @PresN: Hm, you are right:
- @Mr. Stradivarius: I think it's actually that Module:Disambiguation only looks for disambiguation templates, but set index pages have set index templates, so they don't get counted by the module as a disambiguation page, so Module:Pagetype is saying they're "article". Either Module:Disambiguation should treat those like disambig pages, or else Module:Pagetype should call a Module:Set index with its own regex patterns to handle set index pages. --PresN 11:48, 30 August 2023 (UTC)
- @PresN: I tracked the problem down to Module:WikiProject banner. It uses Module:Pagetype here, and then compares the result to the string "article" here. This should probably be changed to a namespace check. — Mr. Stradivarius ♪ talk ♪ 02:55, 30 August 2023 (UTC)
- @Mr. Stradivarius and MSGJ: The WikiProject classification for some disambiguation pages such as Dragon Quest Heroes moved from being "NA-importance" by default to "Unknown-importance" as of today; since no change was made to Wikiproject banner shell, I think that this change may have affected that template/module. In looking at what moved and what didn't, it appears that "set index articles" are now no longer "NA" by default, while "normal" disambiguation articles are still handled correctly. I'm presuming that the fix needs to be applied to Wikiproject banner shell, not here, but replying here since there was an active discussion. --PresN 02:21, 30 August 2023 (UTC)
- @MSGJ: I think changing the default would break too many things. Changing to automatic disambiguation page detection has already broken the categories used by Template:Short description, and it is difficult to tell what else might break by changing the default wording from "page" to "disambiguation page". — Mr. Stradivarius ♪ talk ♪ 13:19, 29 August 2023 (UTC)
- Thanks very much. I'll test it very soon when I get some time. I can use
- I have gone ahead and deployed the changes to the main module. Please let me know if you spot any issues. Best — Mr. Stradivarius ♪ talk ♪ 13:39, 28 August 2023 (UTC)
- @MSGJ: I have implemented disambiguation page detection at Module:Pagetype/sandbox. At the moment, this still outputs the default "page" for disambiguation pages. Disambiguation detection works like redirect detection - it is on by default, and is checked before looking at
- @Mr. Stradivarius just a little reminder if you have time to look at this :) Would it also be possible for
- Time is one thing I don't have the luxury of right now... but perhaps I can take a look at some point in the next few weeks. — Mr. Stradivarius ♪ talk ♪ 00:25, 19 May 2023 (UTC)
- Lots of WP:Set index articles are marked as disambiguation at WikiData... (maybe this isn't about WikiData, but I think I saw another post about it) Christian75 (talk) 10:39, 18 May 2023 (UTC)
- No, we are not currently using wikidata. That was an option explored at Module:Disambiguation but it seems not worthwhile. — Martin (MSGJ · talk) 10:42, 18 May 2023 (UTC)
Detecting pages with Template:Wiktionary redirect and other soft redirects
edit@PARAKANYAA suggested at Wikipedia talk:Content assessment that we should automatically detect pages using Template:Wiktionary redirect and its redirects, and automatically classify them as redirects. It seems we could the same with Template:Soft redirect and its redirects. Are there any other relevant templates? — Martin (MSGJ · talk) 22:16, 9 January 2024 (UTC)
- @MSGJ I think all the templates are listed at Wikipedia:Wikimedia sister projects#Specialized soft redirect templates. PARAKANYAA (talk) 22:22, 9 January 2024 (UTC)
- Wow okay, and you can bet that each template has about 10 redirects, so that's quite a lot of searching in the page text — Martin (MSGJ · talk) 22:23, 9 January 2024 (UTC)
- Sorry D: PARAKANYAA (talk) 22:37, 9 January 2024 (UTC)
- I have created Module:Pagetype/setindex and Module:Pagetype/softredirect in preparation. Are there any other types that we could auto-classify? — Martin (MSGJ · talk) 21:07, 17 January 2024 (UTC)
- Sorry D: PARAKANYAA (talk) 22:37, 9 January 2024 (UTC)
- Wow okay, and you can bet that each template has about 10 redirects, so that's quite a lot of searching in the page text — Martin (MSGJ · talk) 22:23, 9 January 2024 (UTC)
Code now ready for testing in Module:Pagetype/sandbox. Some tests can be seen at the bottom of Template:Pagetype/testcases. If Mr. Stradivarius was more active, I might ask him to check my code. My intention is to remove the call to Module:Disambiguation altogether as the code is mostly duplicated — Martin (MSGJ · talk) 22:34, 19 January 2024 (UTC)
- @MSGJ: Could you also add test cases to Module:Pagetype/testcases? There should be test cases there as well so that future updates to the code don't break the functionality you are adding. I designed the test cases so that you can specify an arbitrary "group name" (just a short description of the general kind of thing the test is testing), the arguments to the template, and the expected result. If you add more tests like that to the
tests
table they should just work. Also, please add any titles you use in the tests to themMockTitle.registerMockTitles
call at the top of the test cases and mock any fields that you will use. This ensures that the tests won't break if someone edits the actual wiki page in the future. You can see Module:Mock title for the different options you can use, but probably I guess you just need to copy the entry for "Alien" (a disambiguation page) and change the content. — Mr. Stradivarius ♪ talk ♪ 00:26, 20 January 2024 (UTC)- Sure, will look at that. Can I ask a question? I assume that lines 25-27 of Module:Disambiguation are not needed here because we are already checking for redirects in line 210. Also, why are you using
mRedirect.getTargetFromText(content) ~= nil
rather than justluaIsRedirect
in there? - And if this works out well, can we get your bot to update these lists like it currently does for the dab pages? — Martin (MSGJ · talk) 12:30, 20 January 2024 (UTC)
I assume that lines 25-27 of Module:Disambiguation are not needed here because we are already checking for redirects in line 210.
Yes, that looks right to me. We shouldn't need a duplicate check.Also, why are you using
I don't remember the reason I wrote it that way. Maybe something to do with double redirects? There was definitely something that you had to parse the content for, rather than just checking the title object, but I don't remember the details, and I'm not sure if it still applies today.mRedirect.getTargetFromText(content) ~= nil
rather than justluaIsRedirect
in there?And if this works out well, can we get your bot to update these lists like it currently does for the dab pages?
Yes, it should be fairly easy to adapt (especially if we use the same format for all the data pages), and I would be willing to run it on the additional pages. Best — Mr. Stradivarius ♪ talk ♪ 16:24, 20 January 2024 (UTC)- Also, one thing I noticed about the code - you can add a
break
statement after line 142, which will stop the algorithm checking all of the templates on a page if it finds a match. — Mr. Stradivarius ♪ talk ♪ 16:28, 20 January 2024 (UTC)
- @Mr. Stradivarius for some reason when I added Module:Pagetype/testcases#L-44 as a mock title, suddenly 7 unrelated tests failed. They seem to be all the tests which do not specify the page name. All my new tests are working correctly. — Martin (MSGJ · talk) 21:47, 21 January 2024 (UTC)
- @MSGJ: This indicates a bug somewhere, but I don't have time right now to look through the code to find out where it is. I might have another look tomorrow. — Mr. Stradivarius ♪ talk ♪ 16:15, 22 January 2024 (UTC)
- Okay thanks. I suspect a bug in Module:Mock title rather than this module — Martin (MSGJ · talk) 16:38, 22 January 2024 (UTC)
- @MSGJ: I found the issue. You added the string
{{Soft redirect|meta:Wikipedia usage statistics}}
to Module:Pagetype/testcases, and as the module treats Module talk:Pagetype/testcases as the current page, it looks through the content of Module:Pagetype/testcases, finds that string, and assumes that the module must be a soft redirect. This wasn't a problem with disambiguation templates as the check for those was limited to the main namespace, but soft redirect detection is done in every namespace.I'm in two minds as to how to fix this. The obvious way would be to also check the page's content model before doing the template check, but checking the content model increments the expensive function count for pages other than the current page, which might cause problems in templates that depend on this module. The alternative is to exclude namespaces that typically have different content models, like module space,
and userspace JS/CSS pages. This will be more of a pain to code and will be wrong for pages that have their content model changed manually, but it will avoid breaking dependent templates. I think the latter solution will be better, as I think there is a high probability of pages being broken by the increase in expensive function count if we choose the former. (This is just an assumption, however; I haven't checked in detail.)While I am thinking about it, there is also a similar problem with
<nowiki>...</nowiki>
tags; it is possible to write<nowiki>{{soft redirect}}</nowiki>
on a wiki page, and this will not be parsed as a soft redirect, but this module will treat it as one. To avoid false positives in discussions etc. where people are talking about soft redirects, we should also detect whether template invocations are contained in<nowiki>...</nowiki>
blocks or not. — Mr. Stradivarius ♪ talk ♪ 07:15, 23 January 2024 (UTC)- Actually, userspace CSS/JS pages should not be excluded, as they are actually categorised if you add a comment like
/* {{soft redirect}} */
to them. If I remember correctly, this is behaviour from before content models were added to MediaWiki; the ability to categorise JS/CSS pages was briefly removed, but enabled again after users complained. — Mr. Stradivarius ♪ talk ♪ 07:29, 23 January 2024 (UTC) - I added two new test cases and updated the rest of the tests to make it more obvious what is causing the test failures. — Mr. Stradivarius ♪ talk ♪ 08:14, 23 January 2024 (UTC)
- Thanks for looking into this. Alternatively we could just restrict the soft redirect detection to mainspace. I think we may be opening a can of worms by trying to ignore code like nowiki which deactivates the template. There are numerous other ways it can be done, e.g. with pre tags or HTML comments. Sounds like a coder's nightmare! — Martin (MSGJ · talk) 09:04, 23 January 2024 (UTC)
- I have another suggestion. We can use the size of the page to determine whether it is likely to be soft redirect. I would suspect anything greater than 1000 bytes is extremely unlikely to be a soft redirect. — Martin (MSGJ · talk) 21:51, 24 January 2024 (UTC)
- @MSGJ: I had a go at stripping out nowiki, pre, syntaxhighlight and source tags, as well as HTML comments. The code is in the sandbox, and the tests are all passing now. The parsing isn't perfect, but it should work for 99% of cases. Are there any other tags or markup that we should filter out? — Mr. Stradivarius ♪ talk ♪ 09:14, 25 January 2024 (UTC)
- Wow, okay. No I can't think of any others. Can I just check if
<!--xxx-->{{soft redirect}}<!--xxx-->
will be detected or will it be greedy and ignore everything between the first open and last close? — Martin (MSGJ · talk) 09:20, 25 January 2024 (UTC) - To avoid reinventing the wheel, you might look at Module:Wikitext Parsing#PrepareText — Martin (MSGJ · talk) 09:31, 25 January 2024 (UTC)
- I've added this to the sandbox and the testcases seem to be working okay — Martin (MSGJ · talk) 15:17, 31 January 2024 (UTC)
- Done — Martin (MSGJ · talk) 20:26, 31 January 2024 (UTC)
- @MSGJ On the initial example I used, 'Murica, it seems to have had a... strange result. The shell now says redirect, but still classifies as unassessed and the shell doesn't show the redirect icon. If I'm missing something, sorry. PARAKANYAA (talk) 22:22, 31 January 2024 (UTC)
- Yes I think I might need to update Module:Class mask and/or Module:Banner shell as well — Martin (MSGJ · talk) 22:27, 31 January 2024 (UTC)
- Working now I think @PARAKANYAA — Martin (MSGJ · talk) 12:48, 1 March 2024 (UTC)
- @MSGJ Thank you very much :) PARAKANYAA (talk) 21:16, 1 March 2024 (UTC)
- @MSGJ On the initial example I used, 'Murica, it seems to have had a... strange result. The shell now says redirect, but still classifies as unassessed and the shell doesn't show the redirect icon. If I'm missing something, sorry. PARAKANYAA (talk) 22:22, 31 January 2024 (UTC)
- Wow, okay. No I can't think of any others. Can I just check if
- @MSGJ: I had a go at stripping out nowiki, pre, syntaxhighlight and source tags, as well as HTML comments. The code is in the sandbox, and the tests are all passing now. The parsing isn't perfect, but it should work for 99% of cases. Are there any other tags or markup that we should filter out? — Mr. Stradivarius ♪ talk ♪ 09:14, 25 January 2024 (UTC)
- I have another suggestion. We can use the size of the page to determine whether it is likely to be soft redirect. I would suspect anything greater than 1000 bytes is extremely unlikely to be a soft redirect. — Martin (MSGJ · talk) 21:51, 24 January 2024 (UTC)
- Actually, userspace CSS/JS pages should not be excluded, as they are actually categorised if you add a comment like
- @MSGJ: I found the issue. You added the string
- Okay thanks. I suspect a bug in Module:Mock title rather than this module — Martin (MSGJ · talk) 16:38, 22 January 2024 (UTC)
- @MSGJ: This indicates a bug somewhere, but I don't have time right now to look through the code to find out where it is. I might have another look tomorrow. — Mr. Stradivarius ♪ talk ♪ 16:15, 22 January 2024 (UTC)
- Sure, will look at that. Can I ask a question? I assume that lines 25-27 of Module:Disambiguation are not needed here because we are already checking for redirects in line 210. Also, why are you using
Mr. Stradivarius when you have a chance, can you get your bot working on Module:Pagetype/setindex, Module:Pagetype/softredirect and Module:Pagetype/disambiguation. Maybe look at moving Module:Disambiguation/templates over? Thanks — Martin (MSGJ · talk) 20:28, 31 January 2024 (UTC)
- Filed a BRFA here. — Mr. Stradivarius ♪ talk ♪ 03:24, 17 February 2024 (UTC)
- Also, I don't think moving Module:Disambiguation/templates is necessary, as it is also being used in Module:Disambiguation. The situation now seems fine to me. — Mr. Stradivarius ♪ talk ♪ 03:27, 17 February 2024 (UTC)
- I guess I was wondering if Module:Disambiguation was still needed, given how we have moved most of its functionality here? It might make sense to move the isDisambiguationPage function to Module:Pagetype to avoid duplication of code. — Martin (MSGJ · talk) 12:48, 1 March 2024 (UTC)
Recent change causing some problems with reports and bot actions
editI am unable to find the discussion that led to this change, but it may be causing problems with reports and bot actions. Plastikspork, do you have a link to the discussion? – Jonesey95 (talk) 04:07, 16 February 2024 (UTC)
- It's at User talk:MSGJ#Module:Pagetype — Martin (MSGJ · talk) 09:18, 16 February 2024 (UTC)
- Jonesey95, that change should have reduced transclusions, by eliminating some transclusions of non-existing pages. But, the change right before it may have increased transclusions. Thanks! Plastikspork ―Œ(talk) 15:04, 16 February 2024 (UTC)
- All I know is that the database report changed on the day after the second edit to this module. I know there are sometimes delays, but usually the simple explanation is the one to look at. – Jonesey95 (talk) 16:31, 16 February 2024 (UTC)
- Jonesey95, that change should have reduced transclusions, by eliminating some transclusions of non-existing pages. But, the change right before it may have increased transclusions. Thanks! Plastikspork ―Œ(talk) 15:04, 16 February 2024 (UTC)
Request update of Module:Pagetype/setindex (18 February 2024)
editThis edit request to Module:Pagetype/setindex has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Bot comment: StradBot has detected that Module:Pagetype/setindex needs to be updated. This is due to a template being added or removed from Category:Set index article templates, or to a redirect to one of those templates being added or removed. The bot has saved the new page content in Module:Pagetype/setindex/sandbox (diff). Please review this and update the module if necessary. StradBot (talk) 16:07, 18 February 2024 (UTC)
- Note: the last sandbox edit should be easier to read than the diff between the sandbox and the main module. — Mr. Stradivarius ♪ talk ♪ 16:14, 18 February 2024 (UTC)
- @Mr. Stradivarius: This added Template:Infobox family name/doc to the list of templates, which is clearly wrong. It was previously a redirect with content, which may have caused confusion, and I've now replaced it with a bare redirect. * Pppery * it has begun... 16:58, 18 February 2024 (UTC)
- It also added Template:family name, a redirect to Template:infobox name, which is used on pages like Smith (surname) that are clearly not set indices. Those seem to be the only two additions, neither of which is useful IMO, so Not done * Pppery * it has begun... 17:02, 18 February 2024 (UTC)
- @Pppery: Thanks for looking into this. I'll think of the best way to address this tomorrow. Could you also check if Module:Pagetype/softredirect/sandbox (diff) looks OK? There was a Pywikibot issue preventing me from saving the edit request for that page, but the module sandbox itself was saved successfully. — Mr. Stradivarius ♪ talk ♪ 17:11, 18 February 2024 (UTC)
- Sorry, no. I see nonsense like Template:Barcelona Metro line 10 and Template:Taxonomy/Olindiasidae. I would also weakly prefer to exclude templates like Template:Soft redirect with Wikidata item from the list, since they indicate the page is already a soft redirect because of another template rather than itself making the page a soft redirect, but if that's not possible to code up I would be fine with adding them. * Pppery * it has begun... 17:17, 18 February 2024 (UTC)
- I fixed the bot - the issue was that I was using Pywikibot's BasePage.backlinks method instead of the BasePage.redirects method. There are more details on GitHub. Module:Pagetype/softredirect/sandbox should also be improved, but the Pywikibot issue that prevented me from saving the second edit request is still occurring, so the bot failed to leave an edit request for it; I will also need to get that fixed before finishing the trial. — Mr. Stradivarius ♪ talk ♪ 16:04, 20 February 2024 (UTC)
- Sorry, no. I see nonsense like Template:Barcelona Metro line 10 and Template:Taxonomy/Olindiasidae. I would also weakly prefer to exclude templates like Template:Soft redirect with Wikidata item from the list, since they indicate the page is already a soft redirect because of another template rather than itself making the page a soft redirect, but if that's not possible to code up I would be fine with adding them. * Pppery * it has begun... 17:17, 18 February 2024 (UTC)
- @Pppery: Thanks for looking into this. I'll think of the best way to address this tomorrow. Could you also check if Module:Pagetype/softredirect/sandbox (diff) looks OK? There was a Pywikibot issue preventing me from saving the edit request for that page, but the module sandbox itself was saved successfully. — Mr. Stradivarius ♪ talk ♪ 17:11, 18 February 2024 (UTC)
Request update of Module:Pagetype/setindex (20 February 2024)
editThis edit request to Module:Pagetype/setindex has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Bot comment: StradBot has detected that Module:Pagetype/setindex needs to be updated. This is due to a template being added or removed from Category:Set index article templates, or to a redirect to one of those templates being added or removed. The bot has saved the new page content in Module:Pagetype/setindex/sandbox (diff). Please review this and update the module if necessary. StradBot (talk) 15:38, 20 February 2024 (UTC)
- This edit wouldn't change the content of the setindex module, only the order and the formatting. As it would only be a cosmetic edit, I am deactivating this edit request. Future bot runs will only leave an edit request if the sandbox version changes, so no other action is necessary. The bot will leave its next edit request when the sandbox needs updating (i.e. when any of the templates in Category:Set index article templates or their redirects change). — Mr. Stradivarius ♪ talk ♪ 15:57, 20 February 2024 (UTC)
Protected edit request on 21 March 2024 - Improve execution time
editThis edit request to Module:Pagetype has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Improves the execution time of this module by about 2 to 3 times by merging repeat calls to some intensive functions and calculating all templates once to avoid excessive calls to gmatch/ustring. Quite important for Module:WikiProject banner, which has started to rarely hit the lua timeout error from time to time on large pages like Talk:List of common misconceptions, with a significant amount of the execution time being this module. No change to any output or functionality (passes all testcases). Aidan9382 (talk) 21:58, 21 March 2024 (UTC)
- Temporarily disabled since I intend to make further changes. Aidan9382 (talk) 12:27, 22 March 2024 (UTC)
- Re-activated the edit request. Now has better performance in extremely specific circumstances and also fixes a bug in parseContent where explicitly not allowing soft redirect/sia/dab would not work and would revert to giving the default (this bug existed before my changes, there was just no testcase for that specific case). Aidan9382 (talk) 17:30, 22 March 2024 (UTC)
- Done — Martin (MSGJ · talk) 19:28, 22 March 2024 (UTC)
Pages under discussion
editWhen a redirect is proposed for deletion, it stops being detected as a redirect. Would it be possible to fix this, perhaps by looking for the literal text #REDIRECT on the page? There might be other cases, e.g. disambiguation pages too — Martin (MSGJ · talk) 11:47, 3 May 2024 (UTC)
- @MSGJ: Currently we just check if the title object itself considers the page a redirect for calculating that. Searching for just the literal string
#REDIRECT
by itself would be a bad idea (this page itself would pick up if we did that), and searching for #REDIRECT in the correct context probably wouldn't be a great idea for the same reason (easy to false flag). If the only issue is redirect pages that are under discussion, the simplest solution would be to just add a check for the RfD template onto the existing parseContent system, which shouldn't be difficult to implement. Does that sound like it'd fix your issue? Also, I'm unsure what you mean when you reference disambiguation pages. Aidan9382 (talk) 21:33, 5 May 2024 (UTC)- Yes, that should work. I think the code to look for would be
#invoke:RfD
. Forget about dab pages, wasn't thinking straight. Thanks — Martin (MSGJ · talk) 20:00, 6 May 2024 (UTC)- I've made changes in the sandbox and created Module:Pagetype/rfd, and it should be ready for proper testing (I've only done simplistic testcases so far). If everything works, then this is fine to move to live, since there's no other parts needed. The output of it can be controlled by setting the
|rfd=
parameter and by default it returnsredirect
. Aidan9382 (talk) 22:42, 6 May 2024 (UTC)- On second thought, it would probably be more intuitive if rfds followed the same classification as a regular redirect if
|redirect=
is used instead of having a seperate param (|rfd=
) for this very specific case, so I've changed that to be the case instead. Aidan9382 (talk) 22:59, 6 May 2024 (UTC)- All looks good to me. Thanks for your help — Martin (MSGJ · talk) 07:52, 7 May 2024 (UTC)
- I've deployed this, thanks again! — Martin (MSGJ · talk) 08:52, 9 May 2024 (UTC)
- On second thought, it would probably be more intuitive if rfds followed the same classification as a regular redirect if
- I've made changes in the sandbox and created Module:Pagetype/rfd, and it should be ready for proper testing (I've only done simplistic testcases so far). If everything works, then this is fine to move to live, since there's no other parts needed. The output of it can be controlled by setting the
- Yes, that should work. I think the code to look for would be
Subpages of talk pages
editSubpages in Main talk space are currently classified as articles but their respective subject page is not an article, it usually doesn't exist (e.g. Talk:Multiverse (Marvel Cinematic Universe)/FAQ). It is not clear how we should classify them but they should probably return "page" instead of "article" — Martin (MSGJ · talk) 07:55, 7 May 2024 (UTC)
- Had a play around but not sure how to achieve this. Detecting whether it's a subpage does not work because we are usually looking at the subject page not the talk page. Checking the existence of the page would work, but I don't really want to add an expensive parser function to every call of this module ... — Martin (MSGJ · talk) 20:58, 7 May 2024 (UTC)
- AC/DC is an article but Multiverse (Marvel Cinematic Universe)/FAQ is not an article — Martin (MSGJ · talk) 21:00, 7 May 2024 (UTC)
- I agree with wanting to avoid adding an expensive call to every use, however it turns out the check for
title.isRedirect
indetectRedirects
(the first check done) is already expensive, so this might not be an issue. Still thinking of a nice way to solve this issue, but nothing's come to mind yet. Aidan9382 (talk) 21:20, 7 May 2024 (UTC)- Can
title.isSubpage
help here (with maybe checkingtitle.inNamespace
with it)? Gonnym (talk) 07:20, 8 May 2024 (UTC)- I don't think so, unfortunately. I created Module:IsSubpage to test this.
{{#invoke:IsSubpage|main|page=Multiverse (Marvel Cinematic Universe)/FAQ}}
produces false, because it's in mainspace which can't have subpages.{{#invoke:IsSubpage|main|page=AC/DC}}
produces false, ditto.{{#invoke:IsSubpage|main|page=Talk:Multiverse (Marvel Cinematic Universe)/FAQ}}
produces true, which is correct.{{#invoke:IsSubpage|main|page=Talk:AC/DC}}
produces true, which is basically a bug in MediaWiki software.
- The best solution I can think of, is to use
title.exists
when the talk page title looks like it might be a subpage. If it doesn't exist then it's probably not an article — Martin (MSGJ · talk) 09:29, 8 May 2024 (UTC)- Actually we can use
<title.exists
if there is a forward slash anywhere in the title, and it's in mainspace — Martin (MSGJ · talk) 21:14, 9 May 2024 (UTC) - Suggested code [2] makes all the testcases work — Martin (MSGJ · talk) 08:59, 10 May 2024 (UTC)
- Aidan, do you know if the title.exists is evaluated if the first condition is false? I am trying to avoid unnecessary expensive functions. If it is evaluated, then I will put it in a separate "if" block — Martin (MSGJ · talk) 09:05, 10 May 2024 (UTC)
- I can't read the exact code since im on phone right now, but if the statement is like
if A and B then
then B won't be evaluated if A is false/nil. The same logic applies in reverse for an or (B won't evaluate if A is anything other than false/nil). Aidan9382 (talk) 09:08, 10 May 2024 (UTC)- Thanks. Yes you've guessed the situation correctly. But now I have read more, I think we don't need to worry about adding an expensive function. Because we have already called .isRedirect on the same page, so calling .exists will not increment the expensive counter again. — Martin (MSGJ · talk) 09:10, 10 May 2024 (UTC)
- I can't read the exact code since im on phone right now, but if the statement is like
- Aidan, do you know if the title.exists is evaluated if the first condition is false? I am trying to avoid unnecessary expensive functions. If it is evaluated, then I will put it in a separate "if" block — Martin (MSGJ · talk) 09:05, 10 May 2024 (UTC)
- Actually we can use
- I don't think so, unfortunately. I created Module:IsSubpage to test this.
- Can
- I agree with wanting to avoid adding an expensive call to every use, however it turns out the check for
Deployed code. Now pages in mainspace which do not exist are not classified as articles — Martin (MSGJ · talk) 21:47, 12 May 2024 (UTC)
Proposed improved code on the sandbox. Adds support for specific output for non-existent pages using a |nonexistent=
parameter. This will allow {{WikiProject banner shell}} to treat these pages slightly differently. I have also been doing some code simplification. Will not be deployed until I work out why testcase 204 is not working anymore. Seems to be a strange issue with the mock title code (because it works outside the testcases), but will keep playing — Martin (MSGJ · talk) 08:19, 15 May 2024 (UTC)
- Special:Diff/1223642991 appears to be the change that broke it, though I'm struggling to figure out why and I won't be able to test further until later on. Aidan9382 (talk) 09:34, 15 May 2024 (UTC)
- Ok, perhaps the issue may be the mock titles. It appears that when the code grabs
title.subjectPageTitle
ingetTitle
, this title will be the real one, regardless of if a mock title was defined for that name. Whether or not this is the issue thats failing the test case I'm not too sure, but I wouldn't be surprised if it was. Aidan9382 (talk) 14:06, 15 May 2024 (UTC)- The
patchTitleConstructors
function of Module:Mock title is supposed to take care of this, but I don't know enough about it. It seems to work okay in every other namespace though. — Martin (MSGJ · talk) 14:09, 15 May 2024 (UTC)- Other namespaces are still broken, its just it appears them returning "page" due to not existing (even if we said they actually do) appears to still be valid for the given testcases. It's just this specific TimedText case where we start seeing bad behaviour.
patchTitleConstructors
doesn't currently hook the xyzTitle properties, so this is just missing functionality. I can try implement it, but it might take a bit to work out. Aidan9382 (talk) 14:16, 15 May 2024 (UTC)
- Other namespaces are still broken, its just it appears them returning "page" due to not existing (even if we said they actually do) appears to still be valid for the given testcases. It's just this specific TimedText case where we start seeing bad behaviour.
- Hang on. That is actually the only page which does not exist in reality. In which case, could it true that the mock titles have never worked properly? But then why does 205 work? — Martin (MSGJ · talk) 14:17, 15 May 2024 (UTC)
- Since 205 has the ability to be classified by it being a talk page, pagetype runs through its logic using the talk page title instead of the subject page title. Aidan9382 (talk) 14:21, 15 May 2024 (UTC)
- Well, I'm astounded that @Mr. Stradivarius did not implement this correctly. For now I have replaced the tests with a TimedText page which does actually exist, and all tests are passing. — Martin (MSGJ · talk) 14:26, 15 May 2024 (UTC)
- I've made an update to the mock title module in Special:Diff/1223977125 which fixes this edge case of escaping mock titles, and the testcase now works as expected (Strad, if you do see this, maybe review this change, since the hooking is a little bit aggressive and it might have a better implementation). Aidan9382 (talk) 14:34, 15 May 2024 (UTC)
- Maybe one day I'll understand what you did there. But for now, thanks — Martin (MSGJ · talk) 14:38, 15 May 2024 (UTC)
- This is a great start - thank you for the edit. One of the goals of the module is to be able to revert title objects to their original state after each test. To do this, I think you would need to keep track of each title object that is altered when being hooked. I will have a think about how best to do this. At the moment, I think normal title objects which have mock titles hooked in one of their properties will remain altered after the patching function exits. Also, a similar hooking process needs to be implemented for Title.subPageTitle( text ), as that method returns other title objects. Best — Mr. Stradivarius ♪ talk ♪ 15:25, 17 May 2024 (UTC)
- It's more "not yet implemented" than "not implemented correctly". Patches are welcome. :) — Mr. Stradivarius ♪ talk ♪ 14:59, 17 May 2024 (UTC)
- I've made an update to the mock title module in Special:Diff/1223977125 which fixes this edge case of escaping mock titles, and the testcase now works as expected (Strad, if you do see this, maybe review this change, since the hooking is a little bit aggressive and it might have a better implementation). Aidan9382 (talk) 14:34, 15 May 2024 (UTC)
- Well, I'm astounded that @Mr. Stradivarius did not implement this correctly. For now I have replaced the tests with a TimedText page which does actually exist, and all tests are passing. — Martin (MSGJ · talk) 14:26, 15 May 2024 (UTC)
- Since 205 has the ability to be classified by it being a talk page, pagetype runs through its logic using the talk page title instead of the subject page title. Aidan9382 (talk) 14:21, 15 May 2024 (UTC)
- The
- Ok, perhaps the issue may be the mock titles. It appears that when the code grabs
Interface messages
editThere are three different types of page in this namespace:
- MediaWiki:Filetype-missing - valid message but has not been created to override default
- MediaWiki:Duplicate-args-warning - has been created to override default
- Mediawiki:Fghghghg - invalid and non-existent
I notice that ifexist returns false on the first type. This is a valid message and a blue link, containing the default text for this message. You would only create it to overridge that default. I think I would prefer pagetype to identify this as an interface page rather than a non-existent page. — Martin (MSGJ · talk) 14:32, 17 May 2024 (UTC)
- Perhaps
title.isLocal
can be used to distinguish between some of these types — Martin (MSGJ · talk) 15:01, 17 May 2024 (UTC) - Proposed amended code on sandbox. A valid system message will be treated as an interface page even if it does not exist locally — Martin (MSGJ · talk) 09:34, 20 May 2024 (UTC)
Also added a fix for files hosted on Commons, which were being classified as non-existent pages. All testcases are now working, so will deploy this later — Martin (MSGJ · talk) 12:06, 21 May 2024 (UTC)
Sandbox page protection fix
editThis edit request to Module:Pagetype/sandbox has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Could the template protection that got automatically applied to the sandbox be removed? Someone presumably accidentally included it in a major module, but this got quickly fixed and the transclusions have already dropped to just 37. Aidan9382 (talk) 21:16, 10 October 2024 (UTC)
- Done -- WOSlinker (talk) 22:36, 10 October 2024 (UTC)
- Yes that was probably Template:WikiProject Cycling — Martin (MSGJ · talk) 10:46, 11 October 2024 (UTC)
Invalid pages
editThe module fails badly when |page=
is set to an invalid page, e.g.
{{pagetype|page=Talk:Talk:Granville Gee Bee Model A}}
produces Lua error in Module:Pagetype at line 87: attempt to index local 'title' (a nil value). — Martin (MSGJ · talk) 14:55, 10 November 2024 (UTC)
- Because that title is a bad title (mediawiki refuses to resolve it, e.g. [[Talk:Talk:Test]] will not link),
mw.title.new
is returning nil. How you'd want to handle this in the context of page types I'm not sure (an error probably makes sense tbh). Aidan9382 (talk) 15:01, 10 November 2024 (UTC)- Why not just the same as any other non-existent page, e.g. Gjdeoofg does not cause an error — Martin (MSGJ · talk) 15:26, 10 November 2024 (UTC)
- That's just a page that doesn't exist. It's still a valid possible page and therefore has resolvable properties, like a subject title. Pages that e.g. stack namespaces (see [3]) or contain invalid characters like
>
(see [4]) can't exist per the mediawiki software, somw.title.new
returns nil for them, since it doesn't make sense to resolve them. Aidan9382 (talk) 20:34, 10 November 2024 (UTC)- Okay fair enough. I actually didn't know that you couldn't create certain pages — Martin (MSGJ · talk) 21:11, 10 November 2024 (UTC)
- It would be nice to handle the nil value gracefully, but the coding is beyond my skills. And FWIW, I have created pages with stacked namespaces in error in the past, during page moves. Template:Template:A is a valid page name, for example. – Jonesey95 (talk) 13:41, 11 November 2024 (UTC)
- The graceful handling makes sense, I could sandbox that if no one else does. It seems that the namespace stacking is mostly only an issue if the first namespace is
Talk:
, since it would be the talk page of an impossible to resolve article, since it wouldn't be an article if it started with a namespace (for all other namespaces this doesn't appear to be an issue, e.g. Template talk:Talk:E can easily associate with Template:Talk:E). Aidan9382 (talk) 13:51, 11 November 2024 (UTC)- I've changed the sandbox such that the error at least points out the exact issue instead of just erroring later on (see test page). Aidan9382 (talk) 19:32, 12 November 2024 (UTC)
- Looks good — Martin (MSGJ · talk) 19:39, 12 November 2024 (UTC)
- I've changed the sandbox such that the error at least points out the exact issue instead of just erroring later on (see test page). Aidan9382 (talk) 19:32, 12 November 2024 (UTC)
- The graceful handling makes sense, I could sandbox that if no one else does. It seems that the namespace stacking is mostly only an issue if the first namespace is
- It would be nice to handle the nil value gracefully, but the coding is beyond my skills. And FWIW, I have created pages with stacked namespaces in error in the past, during page moves. Template:Template:A is a valid page name, for example. – Jonesey95 (talk) 13:41, 11 November 2024 (UTC)
- Okay fair enough. I actually didn't know that you couldn't create certain pages — Martin (MSGJ · talk) 21:11, 10 November 2024 (UTC)
- That's just a page that doesn't exist. It's still a valid possible page and therefore has resolvable properties, like a subject title. Pages that e.g. stack namespaces (see [3]) or contain invalid characters like
- Why not just the same as any other non-existent page, e.g. Gjdeoofg does not cause an error — Martin (MSGJ · talk) 15:26, 10 November 2024 (UTC)
class parameter
editIn olden days, we had no way of detecting disambiguation pages and other types of page so we used to pass the |class=
parameter to this module. I'm wondering if this is still needed now — Martin (MSGJ · talk) 18:02, 16 November 2024 (UTC)
- As far as I can tell the functionality boils down to "if parameter 1 is
na
and the page is in mainspace, returnpage
(or something custom) instead ofarticle
", and that's it. It does give me the vibe of an old hacky-ish fix that implemented na-rating handling possibly at a lower level than it should've been. It's hard to tell how in use it currently is without adding a category, but this insource search suggests it's still in use in quite a few templates (majoritively wikiprojects, some of which still have a lot of transclusions like {{WikiProject Biography}} and {{WikiProject Television}}), so a decent amount of initial conversion work would probably be required before removing it. Aidan9382 (talk) 21:46, 16 November 2024 (UTC)- Yes, it's in Module:Banner shell but is causing unexpected results so I will be removing it shortly — Martin (MSGJ · talk) 21:52, 16 November 2024 (UTC)