Page MenuHomePhabricator

Scribunto mw.title getContent() method can record templatelinks to special pages
Closed, ResolvedPublic

Description

Scribunto mw.title getContent() method can record templatelinks to special pages.

To reproduce, create Module:Test as follows:

local p = {}

function p.main(frame)
	local t = mw.title.new('Special:BlankPage')
	return t:getContent()
end

return p

Then use it in another page:

{{#invoke:Test|main}}

I think this is a bad behavior for several reasons.

  • getContent() probably shouldn't even work on special pages, as they have no wikitext content. While special page transclusion is a thing, getContent() on a transcludable special page doesn't do that anyway.
  • Special page transclusion does not record templatelinks. (Links to special pages don't record pagelinks, either – and neither does mw.title.exists().)
  • Special:WhatLinksHere doesn't let you view those links. If it did (just comment out 'creatable' => true,), the recorded links don't normalize the page title – e.g. Special:BlankPage and Special:blankpage are distinct.
  • Other code may not expect it either (for example, see T376964, which is how I found this problem originally).

By the way, there's a comment in ParserOutput that warns about the problem with normalization:

			// We don't want to record Special: links in the database, so put them in a separate place.
			// It might actually be wise to, but we'd need to do some normalization.
			$this->mLinksSpecial[$dbk] = 1;

Event Timeline

Change #1091862 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/Scribunto@master] Avoid recording template link to special page in getContent()

https://gerrit.wikimedia.org/r/1091862

T354890 is one use case where templatelink rows to special pages would be legitimate, as special page content would actually be shown on a page, albeit indirectly. (Though then there also needs to be a way to trigger LinksUpdate on a special page.)

Change #1091862 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] Avoid recording template link to special page in getContent()

https://gerrit.wikimedia.org/r/1091862

SD0001 claimed this task.