Page MenuHomePhabricator

ActionInfo throws PHP Fatal "Argument to makeLink() must implement LinkTarget, null given" for pages containing "#redirected[[]]"
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to reproduce:

Found it in logstash: https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2017.07.28/mediawiki?id=AV2Ju-H5CtkHCY6a4ZIr&_g=()

PHP Error: Argument 1 passed to MediaWiki\Linker\LinkRenderer::makeLink() must implement interface MediaWiki\Linker\LinkTarget, null given
t exception.trace	#0 /srv/mediawiki/php-1.30.0-wmf.11/includes/linker/LinkRenderer.php(154): MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.30.0-wmf.11/includes/actions/InfoAction.php(239): MediaWiki\Linker\LinkRenderer->makeLink(NULL)
#2 /srv/mediawiki/php-1.30.0-wmf.11/includes/actions/InfoAction.php(120): InfoAction->pageInfo()
#3 /srv/mediawiki/php-1.30.0-wmf.11/includes/actions/FormlessAction.php(43): InfoAction->onView()
#4 /srv/mediawiki/php-1.30.0-wmf.11/includes/MediaWiki.php(499): FormlessAction->show()
#5 /srv/mediawiki/php-1.30.0-wmf.11/includes/MediaWiki.php(293): MediaWiki->performAction(Article, Title)
#6 /srv/mediawiki/php-1.30.0-wmf.11/includes/MediaWiki.php(868): MediaWiki->performRequest()
#7 /srv/mediawiki/php-1.30.0-wmf.11/includes/MediaWiki.php(523): MediaWiki->main()
#8 /srv/mediawiki/php-1.30.0-wmf.11/index.php(43): MediaWiki->run()
#9 /srv/mediawiki/w/index.php(3): include(string)
#10 {main}

The page is not a redirect but ActionInfo thinks so

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 28 2017, 9:54 PM
Krinkle renamed this task from "#redirected[[]]" has strange effects on ActionInfo to ActionInfo throws PHP Fatal "Argument to makeLink() must implement LinkTarget, null given" for pages containing "#redirected[[]]".Aug 14 2018, 5:02 PM

LinkRenderer::makeLink gets the result of WikiPage::getRedirectTarget which can return null when the page is no longer a redirect.
But makeLink is only called when Title::isRedirect returns true, while getRedirectTarget only returns null when Title::isRedirect returns false, so it seems the title objects used in InfoAction and the WikiPage are out of sync while the page was changed from redirect to content page.

I have no idea how to debug the sync issue. I will upload a patch to avoid this situation.

Change 453435 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Simplify redirect linking in InfoAction

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

Umherirrender triaged this task as Medium priority.Aug 18 2018, 12:00 AM

Change 453435 merged by jenkins-bot:
[mediawiki/core@master] Simplify redirect linking in InfoAction

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

Umherirrender closed this task as Resolved.Aug 20 2018, 8:36 AM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:10 PM