Page MenuHomePhabricator

isDisambiguationPage causes unnecessary inclusion in "Templates used in this page" list
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue:

  • Search Wikipedia for a module that uses the isDisambiguationPage function.
  • Go to "What links here", and click there on a page in the main namespace.
  • Go to edit mode, and scroll down to the "Templates used in this page" list (screenshot attached).

What happens?:
In the list, besides the templates used in the page, pages from the main namespace that are not included in the page also appear.

What should have happened instead?:
Even if we want the cache on these pages to be purged frequently (through the templates used in page tables), we should ensure that the page list doesn't display these.
Or find another solution other than inclusion in this table.

Other information:
The issue was reported on Hebrew Wikipedia, at this link. After investigation, it was found that the issue also exists in all other Wikimedia wikis, for example English Wikipedia.

image.png (1,522×654 px, 98 KB)

Event Timeline

Alien333 subscribed.

I suppose you mean the isDisambiguationPage property of lua mw.title objects added by Extension:Disambiguator.

I suppose you mean the isDisambiguationPage property of lua mw.title objects added by Extension:Disambiguator.

yes.

Pppery subscribed.

I disagree with this conceptually; checking whether the page is a disambiguation page is a kind of transclusion. But whatever.

Pppery moved this task from Backlog to External on the Scribunto board.

Do red links that are created cause the page to pruge? If not, why is more needed here? If so, why can't the same approach be implemented here?
That list helps local developers locate templates when maintenance is needed; showing other pages complicates this process.

I disagree with this conceptually; checking whether the page is a disambiguation page is a kind of transclusion. But whatever.

@Pppery, that list is explicitly titled "Templates used in this preview"; pages not in the template namespace clearly shouldn't appear in it.

That list has always included pages that are not templates. The non-preview version of the same functionality says "Pages transcluded onto the current version of this page", which is more correct.

Okay, fair enough, that makes sense.
But it's still not clear to me why the target of a disambig check should be treated as a transcluded page. There's just one bit of information from that page which affects the calling page (disambig or not); that's still quite far from including the entire page contents.

With Michi's permission, I'll try to elaborate on what he wrote in T401556#11073051 above (after I was given an explanation offline). Michi, if I misunderstood, please feel free to correct me.

As I understand it, the goal of including disambig check targets in that list (or, more precisely, in the table on which the list is based) is to make sure that any edit in the disambig check target page triggers a cache purge in the calling page, thereby making sure that even in case that edit changed the target page's disambig status, the disambig check will always return the correct result.

Michi's question was, how are "red links" (links to non-existing pages) handled in this context? If a page contains a red link, the link's target is not included in the list. What happens when such a page is created? Similarly, what happens when an existing linked page ("blue link" target) is deleted? Do these events trigger a cache purge in the page containing the links?
If the answer is yes, then how does that happen? Is there a mechanism for that, other than including all of the link targets in the list? If so, this mechanism can be used also for the disambig check targets, and this way their inclusion in the list can be avoided.
If the answer is no (i.e., page existence status change doesn't purge the cache of pages linking to it), then why is purging even necessary for the disambig case? Is disambig status change more important than existence status change to justify purging for the former while it is not performed for the latter?

Thanks!

As I see it, a page "transcludes" another page if it depends on any way on the content of that page (as opposed to the existence of it). I'm not trying to argue it is technically necessary, I'm trying to argue that the current behavior is correct as a conceptual matter; the list at the bottom of the edit page should include all pages the page being edited depends on in some way, including by checking whether they are disambiguation pages (it should also include #ifexist links by the same argument, and it currently doesn't, which is T395366) Nevertheless, I'll try to explain how link tracking works.

To answer Michi's questions, red links appear in https://www.mediawiki.org/wiki/Manual:Pagelinks_table, #ifexist links appear in https://www.mediawiki.org/wiki/Manual:Existencelinks_table, and transclusions currently appear https://www.mediawiki.org/wiki/Manual:Templatelinks_table.

Pagelinks and templatelinks show up in Special:WhatLinksHere. Existencelinks currently don't show up there, but they should and the fact that they don't is a bug (T395366).

I think, but am not 100% sure, that the parser then cache purges pages referenced in pagelinks or existencelinks only when a page is created, and repurges pages checked in templatelinks on every edit to a page.

Yes, in theory isDisambiguationPage could go in pagelinks or existencelinks instead (and the parser could repurge those when a page starts or stops being a dab page), or it could not go in any *links table at all (and hence not update cache at all). Nothing technical is stopping that, but I think it would be a bad idea.

See also T268526

@Pppery, thank you very much for the very detailed answer!
I understand, and I agree that it is useful to have a list of all pages affecting a given page; although I'm not sure that the templatelinks table is the best place for that (but I guess that until something like T268526 is implemented, that list can sit in this table, if no better place exists. And thanks for the reference to that task! Also, changing its title to reflect its actual context, which you performed in T406769, is important).

So, if this is the conclusion, I have one more thing to ask: in addition to a list of all pages on which a given page is dependent, it is very useful to have a list of all of the templates transcluded in a given page. When editors look for an error in a page, many times it is originated from a transcluded template. This kind of relation is true for templates, but not e.g. for pages which are targets of disambig checks. This is what brought editors in my "home wiki" to start asking around about this change in the first place.
So, I wanted to ask: if many non-template pages will start populating the templatelinks table in addition to the templates (and rarely some other pages) it used to include, is it possible to add a filtering button / checkbox, which will hide the non-template pages from the list displayed in the page preview? This way, the actual table will include all of the dependencies, in agreement with the principles you described above, but the list displayed in the wiki could be configured to conveniently display the information required for page debugging purposes.

Thanks a lot again!

Feel free to file that as a separate task. Adding namespace filtering to that seems like a vaguely reasonable idea, but not something I care enough to code myself.

(I don't think anything other than the label for the field has actually changed recently; so the list contains the same things as it always has)

Thanks again @Pppery! I just opened a separate feature request, T410208.
I agree with your last comment about the list basically containing the same things, but now - following the introduction of "isDisambiguationPage" - it contains more of them (and even more after T395366 will be resolved).
Thanks a lot again!

I disagree with this conceptually; checking whether the page is a disambiguation page is a kind of transclusion. But whatever.

Indeed. There are dozen of parser functions and magic words (https://www.mediawiki.org/wiki/Help:Magic_words) and even more Lua functions, that all read another page. This is working as expected, and this is important because without it, we would not have change propagation ("RefreshLinks") to purge the cache and re-parse a page after the target is edited to be or not be a disambiguation page.

Note that the #ifexist optimisation of T14019/T395366 would be undesirable here.

Firstly, that function was using pagelinks and not templatelinks, because it only required toggling between existing and not existing (ike blue/red links, based on create/delete/undelete/move, instead of edits as templatelinks). Switching isDisambiguationPage to pagelinks or ifexist-tracking would break cache invalidation, because disambiguation state is something that an edit can change.

Secondly, that change was motivated by WhatLinksHere having confusing entries. Page links are content and so are a useful category on their own, separated and insulated from coding logic in templates. Explaining to someone that ifexist created a page link internally helped someone understand why it was this way, but explaining it did solve the use case of following links in content, and so we changed it.

Template calls within the meta/project coding umbrella and are likewise a useful category as well. Template transclusions always orginate in templating code.

Is there a specific problem or use case here? Or do we have agreement that this is a documentation issue where the only outcome needed is to learn how/why how it works is useful?

[…]
Michi's question was, how are "red links" (links to non-existing pages) handled in this context? If a page contains a red link, the link's target is not included in the list.

I would agree that, if isDisambiguationPage adds a target to templatelinks only if the target exists, that would be a bug worth fixing (by adding it there, or by adding it to existencelinks).

However, I can't reproduce this. It seems to consistently add it, which seems the right behavior. The same way as it would if you wrote {{NotARealTemplate}}.

https://test.wikipedia.org/wiki/Module:Sandbox/Krinkle/2026-T401556

{{#invoke:Sandbox/Krinkle/2026-T401556|main}}
{{#invoke:Sandbox/Krinkle/2026-T401556|main|Wikipedia:Sandbox/Disambig}}
{{#invoke:Sandbox/Krinkle/2026-T401556|main|Wikipedia:Sandbox/NotFound}}
No, Main Page is not a disambig page.
Yes, Wikipedia:Sandbox/Disambig is a disambig page.
No, Wikipedia:Sandbox/NotFound is not a disambig page.

Pages included in this preview:

  • Main Page (edit) (fully protected)
  • Wikipedia:Sandbox/Disambig (edit)
  • Wikipedia:Sandbox/NotFound (edit)
  • Module:Sandbox/Krinkle/2026-T401556 (edit)