Page MenuHomePhabricator

Special:Log/move: ParameterTypeException: Bad value for parameter $link: must be a MediaWiki\Linker\LinkTarget|MediaWiki\Page\PageReference
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\ParameterTypeException: Bad value for parameter $link: must be a MediaWiki\Linker\LinkTarget|MediaWiki\Page\PageReference
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.4/vendor/wikimedia/assert/src/Assert.php(105)
#0 /srv/mediawiki/php-1.37.0-wmf.4/includes/cache/LinkBatch.php(133): Wikimedia\Assert\Assert::parameterType(array, NULL, string)
#1 /srv/mediawiki/php-1.37.0-wmf.4/includes/logging/LogPager.php(430): LinkBatch->addObj(NULL)
#2 /srv/mediawiki/php-1.37.0-wmf.4/includes/pager/IndexPager.php(599): LogPager->getStartBody()
#3 /srv/mediawiki/php-1.37.0-wmf.4/includes/specials/SpecialLog.php(274): IndexPager->getBody()
#4 /srv/mediawiki/php-1.37.0-wmf.4/includes/specials/SpecialLog.php(156): SpecialLog->show(FormOptions, array)
#5 /srv/mediawiki/php-1.37.0-wmf.4/includes/specialpage/SpecialPage.php(646): SpecialLog->execute(string)
#6 /srv/mediawiki/php-1.37.0-wmf.4/includes/specialpage/SpecialPageFactory.php(1396): SpecialPage->run(string)
#7 /srv/mediawiki/php-1.37.0-wmf.4/includes/MediaWiki.php(313): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#8 /srv/mediawiki/php-1.37.0-wmf.4/includes/MediaWiki.php(916): MediaWiki->performRequest()
#9 /srv/mediawiki/php-1.37.0-wmf.4/includes/MediaWiki.php(550): MediaWiki->main()
#10 /srv/mediawiki/php-1.37.0-wmf.4/index.php(53): MediaWiki->run()
#11 /srv/mediawiki/php-1.37.0-wmf.4/index.php(46): wfIndexMain()
#12 /srv/mediawiki/w/index.php(3): require(string)
#13 {main}
Impact

Inaccessible logs and contributions history for some users.

Notes

Reproducible at URL.

One of these so far for 1.37.0-wmf.4.

Looks like that code has changed recently - LinkBatch: replace Title with PageReference in method signatures. cc: @daniel as author on that one.

Details

Request URL
https://tr.wikipedia.org/wiki/%C3%96zel:G%C3%BCnl%C3%BCk/move/Atacame%C3%B1o

Event Timeline

Now that the train has been rolled back, I can open this page and see a likely suspect:

19:51, 7 July 2007 Atacameño talk contribs moved page Tartışma:Gruphepsi to Invalid title (thank)

LogPager is passing something invalid (probably null) to LinkBatch::addObject. LogPager::getStartBody() has this code:

				foreach ( $formatter->getPreloadTitles() as $title ) {
					$lb->addObj( $title );
				}

LogFormatter::getPreloadTitles() is declared to return LinkTarget[]. So that should be fine. I suppose that sometimes, it returns something else.

According to the request URL, the LogFormatter here was MoveLogFormatter. It has:

public function getPreloadTitles() {
		$params = $this->extractParameters();

		return [ Title::newFromText( $params[3] ) ];
	}

Title::newFromText() however can return null if the title is invalid, which apparently was the case here.

The real fix would be not make sure all implementations of getPreloadTitles() always return LinkTargets, and never null.

As a quick fix, LogPager::getStartBody() should call array_filter() on the array returned by getPreloadTitles().

Change 686481 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] LinkBatch: skip bad input

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

brennen triaged this task as Unbreak Now! priority.May 7 2021, 3:36 PM

Train blockers are UBN!.

Change 686481 merged by jenkins-bot:

[mediawiki/core@master] LinkBatch: skip bad input

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

Change 685901 had a related patch set uploaded (by Jforrester; author: Daniel Kinzler):

[mediawiki/core@wmf/1.37.0-wmf.4] LinkBatch: skip bad input

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

Change 685901 merged by jenkins-bot:

[mediawiki/core@wmf/1.37.0-wmf.4] LinkBatch: skip bad input

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

Mentioned in SAL (#wikimedia-operations) [2021-05-07T17:50:51Z] <brennen@deploy1002> Synchronized php-1.37.0-wmf.4/includes/cache/LinkBatch.php: Backport: [[gerrit:685901|LinkBatch: skip bad input (T282180 T282070)]] (duration: 01m 06s)

Jdforrester-WMF added a subscriber: Jdforrester-WMF.

Confirm, Resolved as far as the train blocker part matters. If there's follow-up work, please re-open and detach.