Page MenuHomePhabricator

Moving any page results in: TypeError: Return value of TitleArrayFromResult::current() must be an instance of Title, boolean returned
Closed, ResolvedPublicBUG REPORT

Description

Trying to move any page at Beta enwikisource (e.g. https://en.wikisource.beta.wmflabs.org/wiki/Special:MovePage/Font_tests) results in an error like the following:

[YTngAioMF3gg3mw@WKwbZQAAAAw] /wiki/Special:MovePage/Font_tests TypeError: Return value of TitleArrayFromResult::current() must be an instance of Title, boolean returned

Backtrace:

from /srv/mediawiki/php-master/includes/TitleArrayFromResult.php(75)
#0 /srv/mediawiki/php-master/includes/Title.php(2785): TitleArrayFromResult->current()
#1 /srv/mediawiki/php-master/includes/specials/SpecialMovepage.php(317): Title->hasSubpages()
#2 /srv/mediawiki/php-master/includes/specials/SpecialMovepage.php(212): MovePageForm->showForm(array)
#3 /srv/mediawiki/php-master/includes/specialpage/SpecialPage.php(647): MovePageForm->execute(string)
#4 /srv/mediawiki/php-master/includes/specialpage/SpecialPageFactory.php(1366): SpecialPage->run(string)
#5 /srv/mediawiki/php-master/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#6 /srv/mediawiki/php-master/includes/MediaWiki.php(925): MediaWiki->performRequest()
#7 /srv/mediawiki/php-master/includes/MediaWiki.php(559): MediaWiki->main()
#8 /srv/mediawiki/php-master/index.php(53): MediaWiki->run()
#9 /srv/mediawiki/php-master/index.php(46): wfIndexMain()
#10 /srv/mediawiki/w/index.php(3): require(string)
#11 {main}

Also at Beta Commons: https://commons.wikimedia.beta.wmflabs.org/wiki/Special:MovePage/Artturi

Event Timeline

Change 720069 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] title: Avoid calling TitleArray::current on empty iterator

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

The real type hint was suggested on code review.

TitleArrayFromResult is using Title::newFromRow which always returns a Title object. When the TitleArray is instanced with a valid row, it should return something.
When it is instanced with an empty result set, than it is possible the current() returns false. I am not sure if it is okay to call Iterator functions without checking if the iterator has something to iterate

Change 720069 merged by jenkins-bot:

[mediawiki/core@master] title: Avoid calling TitleArray::current on empty iterator

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