Page MenuHomePhabricator

PHP Deprecated: Use of MediaWiki\Parser\ParserOutput::addTemplate with interwiki link was deprecated in MediaWiki 1.42. [Called from MediaWiki\Parser\Parser::fetchTemplateAndTitle]
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   PHP Deprecated: Use of MediaWiki\Parser\ParserOutput::addTemplate with interwiki link was deprecated in MediaWiki 1.42. [Called from MediaWiki\Parser\Parser::fetchTemplateAndTitle]
error.stack_trace
from /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3594)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, string, array)
#1 /srv/mediawiki/php-1.42.0-wmf.26/includes/debug/MWDebug.php(379): trigger_error(string, integer)
#2 /srv/mediawiki/php-1.42.0-wmf.26/includes/debug/MWDebug.php(350): MWDebug::sendRawDeprecated(string, boolean, string)
#3 /srv/mediawiki/php-1.42.0-wmf.26/includes/debug/MWDebug.php(231): MWDebug::deprecatedMsg(string, string, string, integer)
#4 /srv/mediawiki/php-1.42.0-wmf.26/includes/GlobalFunctions.php(773): MWDebug::deprecated(string, string, string, integer)
#5 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/ParserOutput.php(1107): wfDeprecated(string, string)
#6 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3594): MediaWiki\Parser\ParserOutput->addTemplate(MediaWiki\Title\Title, integer, NULL)
#7 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3478): MediaWiki\Parser\Parser->fetchTemplateAndTitle(MediaWiki\Title\Title)
#8 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3219): MediaWiki\Parser\Parser->getTemplateDom(MediaWiki\Title\Title)
#9 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/PPFrame_Hash.php(275): MediaWiki\Parser\Parser->braceSubstitution(array, PPFrame_Hash)
#10 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(2937): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#11 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(1583): MediaWiki\Parser\Parser->replaceVariables(string)
#12 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(691): MediaWiki\Parser\Parser->internalParse(string)
#13 /srv/mediawiki/php-1.42.0-wmf.26/includes/content/WikitextContentHandler.php(376): MediaWiki\Parser\Parser->parse(string, MediaWiki\Title\Title, ParserOptions, boolean, boolean, NULL)
#14 /srv/mediawiki/php-1.42.0-wmf.26/includes/content/ContentHandler.php(1664): WikitextContentHandler->fillParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, MediaWiki\Parser\ParserOutput)
#15 /srv/mediawiki/php-1.42.0-wmf.26/includes/content/Renderer/ContentRenderer.php(67): ContentHandler->getParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams)
#16 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiParse.php(161): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(WikitextContent, MediaWiki\Title\Title, NULL, ParserOptions)
#17 /srv/mediawiki/php-1.42.0-wmf.26/includes/poolcounter/PoolCounterWorkViaCallback.php(73): ApiParse->{closure}()
#18 /srv/mediawiki/php-1.42.0-wmf.26/includes/poolcounter/PoolCounterWork.php(171): MediaWiki\PoolCounter\PoolCounterWorkViaCallback->doWork()
#19 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiParse.php(169): MediaWiki\PoolCounter\PoolCounterWork->execute()
#20 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiParse.php(446): ApiParse->getContentParserOutput(WikitextContent, MediaWiki\Title\Title, NULL, ParserOptions)
#21 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiMain.php(1946): ApiParse->execute()
#22 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiMain.php(922): ApiMain->executeAction()
#23 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiMain.php(893): ApiMain->executeActionWithErrorHandling()
#24 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiEntryPoint.php(158): ApiMain->execute()
#25 /srv/mediawiki/php-1.42.0-wmf.26/includes/MediaWikiEntryPoint.php(199): MediaWiki\Api\ApiEntryPoint->execute()
#26 /srv/mediawiki/php-1.42.0-wmf.26/api.php(44): MediaWiki\MediaWikiEntryPoint->run()
#27 /srv/mediawiki/w/api.php(3): require(string)
#28 {main}
Impact
Notes

New from 1.42.0-wmf.26 they are all from meta.wikimedia.org and specially all from the User namespace?

MediaWiki\Parser\ParserOutput::addTemplate with interwikilink has been deprecated via T361330

Details

Event Timeline

Yeah, the requests are definitely coming from the GlobalUserPage extension: https://codesearch.wmcloud.org/search/?q=GlobalUserPageAPIUrl&files=&excludeFiles=&repos=

All of the pages seem to contain a #REDIRECT to a non-local wiki, which is where the user's "real" home page is. Verified that {{:User:cscott}} (which doesn't contain a #REDIRECT) doesn't trigger this, even though https://meta.wikimedia.org/wiki/User:cscott contains a non-local link. So probably an issue with redirect handling to non-local pages.

It's specifically a local transclusion of a page with a #REDIRECT, it doesn't happen if you put the #REDIRECT directly in the action=parse&text=.... request, nor does it happen if the page you are transcluding includes a interwiki link but not as a #REDIRECT. So probably something about how #REDIRECT is handled as a magic word when it is *not* stripped by WikitextContentHandler::extractRedirectTargetAndText. Also happens if parsoid=1 in the API request, oddly (?) enough, since Parsoid by default (a) doesn't strip the #REDIRECT and (b) handles the #REDIRECT locally (generating a <link>) rather than calling the core magic word. Hmm. The stack trace in the Parsoid case is:

from /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3594)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, string, array)
#1 /srv/mediawiki/php-1.42.0-wmf.26/includes/debug/MWDebug.php(379): trigger_error(string, integer)
#2 /srv/mediawiki/php-1.42.0-wmf.26/includes/debug/MWDebug.php(350): MWDebug::sendRawDeprecated(string, boolean, string)
#3 /srv/mediawiki/php-1.42.0-wmf.26/includes/debug/MWDebug.php(231): MWDebug::deprecatedMsg(string, string, string, integer)
#4 /srv/mediawiki/php-1.42.0-wmf.26/includes/GlobalFunctions.php(773): MWDebug::deprecated(string, string, string, integer)
#5 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/ParserOutput.php(1107): wfDeprecated(string, string)
#6 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3594): MediaWiki\Parser\ParserOutput->addTemplate(MediaWiki\Title\Title, integer, NULL)
#7 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3478): MediaWiki\Parser\Parser->fetchTemplateAndTitle(MediaWiki\Title\Title)
#8 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(3219): MediaWiki\Parser\Parser->getTemplateDom(MediaWiki\Title\Title)
#9 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/PPFrame_Hash.php(275): MediaWiki\Parser\Parser->braceSubstitution(array, PPFrame_Hash)
#10 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parser.php(2937): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#11 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parsoid/Config/DataAccess.php(386): MediaWiki\Parser\Parser->replaceVariables(string, PPFrame_Hash)
#12 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wikitext/Wikitext.php(43): MediaWiki\Parser\Parsoid\Config\DataAccess->preprocessWikitext(MediaWiki\Parser\Parsoid\Config\PageConfig, MediaWiki\Parser\ParserOutput, string)
#13 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TT/TemplateHandler.php(1067): Wikimedia\Parsoid\Wikitext\Wikitext::preprocess(Wikimedia\Parsoid\Config\Env, string)
#14 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TT/TemplateHandler.php(1110): Wikimedia\Parsoid\Wt2Html\TT\TemplateHandler->expandTemplate(Wikimedia\Parsoid\Wt2Html\TT\TemplateEncapsulator)
#15 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TT/TemplateHandler.php(1151): Wikimedia\Parsoid\Wt2Html\TT\TemplateHandler->onTemplate(Wikimedia\Parsoid\Tokens\SelfclosingTagTk)
#16 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TT/TokenHandler.php(138): Wikimedia\Parsoid\Wt2Html\TT\TemplateHandler->onTag(Wikimedia\Parsoid\Tokens\SelfclosingTagTk)
#17 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TokenTransformManager.php(113): Wikimedia\Parsoid\Wt2Html\TT\TokenHandler->process(array)
#18 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TokenTransformManager.php(176): Wikimedia\Parsoid\Wt2Html\TokenTransformManager->processChunk(array)
#19 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TokenTransformManager.php(174): Wikimedia\Parsoid\Wt2Html\TokenTransformManager->processChunkily(string, array)
#20 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/TreeBuilder/TreeBuilderStage.php(476): Wikimedia\Parsoid\Wt2Html\TokenTransformManager->processChunkily(string, array)
#21 [internal function]: Wikimedia\Parsoid\Wt2Html\TreeBuilder\TreeBuilderStage->processChunkily(string, array)
#22 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/DOMPostProcessor.php(963): Generator->current()
#23 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/ParserPipeline.php(170): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->processChunkily(string, array)
#24 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wt2Html/ParserPipelineFactory.php(279): Wikimedia\Parsoid\Wt2Html\ParserPipeline->parseChunkily(string, array)
#25 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Wikitext/ContentModelHandler.php(159): Wikimedia\Parsoid\Wt2Html\ParserPipelineFactory->parse(string)
#26 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Parsoid.php(191): Wikimedia\Parsoid\Wikitext\ContentModelHandler->toDOM(Wikimedia\Parsoid\Ext\ParsoidExtensionAPI)
#27 /srv/mediawiki/php-1.42.0-wmf.26/vendor/wikimedia/parsoid/src/Parsoid.php(232): Wikimedia\Parsoid\Parsoid->parseWikitext(MediaWiki\Parser\Parsoid\Config\PageConfig, MediaWiki\Parser\ParserOutput, array)
#28 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parsoid/ParsoidParser.php(149): Wikimedia\Parsoid\Parsoid->wikitext2html(MediaWiki\Parser\Parsoid\Config\PageConfig, array, NULL, MediaWiki\Parser\ParserOutput)
#29 /srv/mediawiki/php-1.42.0-wmf.26/includes/parser/Parsoid/ParsoidParser.php(253): MediaWiki\Parser\Parsoid\ParsoidParser->genParserOutput(MediaWiki\Parser\Parsoid\Config\PageConfig, ParserOptions)
#30 /srv/mediawiki/php-1.42.0-wmf.26/includes/content/WikitextContentHandler.php(376): MediaWiki\Parser\Parsoid\ParsoidParser->parse(string, MediaWiki\Title\Title, ParserOptions, boolean, boolean, NULL)
#31 /srv/mediawiki/php-1.42.0-wmf.26/includes/content/ContentHandler.php(1664): WikitextContentHandler->fillParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, MediaWiki\Parser\ParserOutput)
#32 /srv/mediawiki/php-1.42.0-wmf.26/includes/content/Renderer/ContentRenderer.php(67): ContentHandler->getParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams)
#33 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiParse.php(161): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(WikitextContent, MediaWiki\Title\Title, NULL, ParserOptions)
#34 /srv/mediawiki/php-1.42.0-wmf.26/includes/poolcounter/PoolCounterWorkViaCallback.php(73): ApiParse->{closure}()
#35 /srv/mediawiki/php-1.42.0-wmf.26/includes/poolcounter/PoolCounterWork.php(171): MediaWiki\PoolCounter\PoolCounterWorkViaCallback->doWork()
#36 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiParse.php(169): MediaWiki\PoolCounter\PoolCounterWork->execute()
#37 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiParse.php(446): ApiParse->getContentParserOutput(WikitextContent, MediaWiki\Title\Title, NULL, ParserOptions)
#38 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiMain.php(1946): ApiParse->execute()
#39 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiMain.php(922): ApiMain->executeAction()
#40 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiMain.php(893): ApiMain->executeActionWithErrorHandling()
#41 /srv/mediawiki/php-1.42.0-wmf.26/includes/api/ApiEntryPoint.php(158): ApiMain->execute()
#42 /srv/mediawiki/php-1.42.0-wmf.26/includes/MediaWikiEntryPoint.php(199): MediaWiki\Api\ApiEntryPoint->execute()
#43 /srv/mediawiki/php-1.42.0-wmf.26/api.php(44): MediaWiki\MediaWikiEntryPoint->run()
#44 /srv/mediawiki/w/api.php(3): require(string)
#45 {main}

The root cause is the redirect resolution inside Parser:statelessFetchTemplate which follows (a limited number of) redirects in order to obtain the "real" template text. It adds each step in the redirect chain to the page dependencies as it goes. The issue is that when redirects point to interwiki links, it goes ahead and adds those external links to the dependencies as well, which eventually causes them to be sent to ParserOutput::addTemplate(). As discussed in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/LabeledSectionTransclusion/+/1004305:

At the moment the call to Parser::fetchTemplateAndTitle (directly or via Parser::getTemplateDom) would register the interwiki as template via ParserOutput::addTemplate and it gets stored in the linktarget table with ns=0 and title=Non-Wiki-Part. When this is a interwiki to a user page, the linktarget has ns=0 and title=User:Name and namespaceDupes.php wants to repair this (the way I have seen this - T355706).

Change #1018732 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies

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

Change #1018732 merged by jenkins-bot:

[mediawiki/core@master] Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies

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

Change #1018692 had a related patch set uploaded (by Jforrester; author: C. Scott Ananian):

[mediawiki/core@wmf/1.42.0-wmf.26] Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies

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

Change #1018693 had a related patch set uploaded (by Jforrester; author: C. Scott Ananian):

[mediawiki/core@REL1_42] Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies

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

Change #1018693 merged by jenkins-bot:

[mediawiki/core@REL1_42] Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies

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

Change #1018692 merged by jenkins-bot:

[mediawiki/core@wmf/1.42.0-wmf.26] Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies

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

Mentioned in SAL (#wikimedia-operations) [2024-04-12T14:05:43Z] <hashar@deploy1002> Started scap: Backport for [[gerrit:1018692|Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies (T362221)]]

Mentioned in SAL (#wikimedia-operations) [2024-04-12T14:08:16Z] <hashar@deploy1002> hashar and jforrester: Backport for [[gerrit:1018692|Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies (T362221)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-04-12T14:22:12Z] <hashar@deploy1002> Finished scap: Backport for [[gerrit:1018692|Parser::statelessFetchTemplate: don't add interwiki redirects to dependencies (T362221)]] (duration: 16m 29s)

hashar closed this task as Resolved.EditedApr 12 2024, 2:24 PM
hashar assigned this task to cscott.

I have deployed the fix and, thanks to the reproducible case, I can confirm that fixed that specific error log :) Thank you!