Page MenuHomePhabricator

Error moving translated category (or any translatable page in a namespace without subpages enabled)
Closed, ResolvedPublic

Description

I am receiving an error when trying to move the translated category, "Wikimedia Foundation Executive Director", to "Wikimedia Foundation Chief Executive Officer and Executive Director" on Meta-Wiki.

Specifically the error is: "PHP fatal error: Argument must implement interface Traversable".

Let me know if cannot be duplicated for some reason, or if there is an obvious fix I am missing. Thank you!

Event Timeline

Varnent triaged this task as High priority.Feb 4 2019, 9:10 PM
Nikerabbit subscribed.
#0 /srv/mediawiki/php-1.33.0-wmf.14/extensions/Translate/tag/SpecialPageTranslationMovePage.php(610): NO_FUNCTION_GIVEN()
#1 /srv/mediawiki/php-1.33.0-wmf.14/extensions/Translate/tag/SpecialPageTranslationMovePage.php(487): SpecialPageTranslationMovePage->getNormalSubpages()
#2 /srv/mediawiki/php-1.33.0-wmf.14/extensions/Translate/tag/SpecialPageTranslationMovePage.php(128): SpecialPageTranslationMovePage->checkMoveBlockers()
#3 /srv/mediawiki/php-1.33.0-wmf.14/includes/specialpage/SpecialPage.php(569): SpecialPageTranslationMovePage->execute(string)
#4 /srv/mediawiki/php-1.33.0-wmf.14/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(string)
#5 /srv/mediawiki/php-1.33.0-wmf.14/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#6 /srv/mediawiki/php-1.33.0-wmf.14/includes/MediaWiki.php(862): MediaWiki->performRequest()
#7 /srv/mediawiki/php-1.33.0-wmf.14/includes/MediaWiki.php(517): MediaWiki->main()
#8 /srv/mediawiki/php-1.33.0-wmf.14/index.php(42): MediaWiki->run()
#9 /srv/mediawiki/w/index.php(3): include(string)
#10 {main}

My first theory was that we are hitting this code path: https://gerrit.wikimedia.org/g/mediawiki/core/+/5f9e9f4e077ffe7b02c2b0236bd2dd61ee56074e/includes/TitleArray.php#43. null probably doesn't implement traversable and goes against the documented return value. On the other hand, I can't find any usages of this hook anywhere.

When trying to move myself I get "The target translatable page "Wikimedia Foundation Chief Executive Officer and Executive Director" exists.". If I use some other name, I can produce the error. I enabled PHP7 beta feature, because of the following:

Here is what HHVM says:

nikerabbit@deploy1001:~$ mwscript eval.php --wiki=metawiki
> var_dump( iterator_to_array( null ) );
[Tue Feb  5 07:09:32 2019] [hphp] [26358:7f8c7726d3c0:0:000001] [] 
Catchable fatal error: Argument must implement interface Traversable in /srv/mediawiki-staging/php-1.33.0-wmf.14/maintenance/eval.php(78)(5115e5fb9d9235debf238ca7b21a059c) : eval()'d code on line 1

Here is what PHP7 says (locally):

twn:/www/dev.translatewiki.net/docroot/w (master)$ php maintenance/eval.php 
var_dump( iterator_to_array> var_dump( iterator_to_array( null ) );
[0d45e7d1b0f8bf46e414c7ad] [no req]   TypeError from line 1 of /www/dev.translatewiki.net/docroot/w/maintenance/eval.php(78) : eval()'d code: Argument 1 passed to iterator_to_array() must implement interface Traversable, null given

And indeed with PHP7 I get:

TypeError from line 610 of /srv/mediawiki/php-1.33.0-wmf.14/extensions/Translate/tag/SpecialPageTranslationMovePage.php: Argument 1 passed to iterator_to_array() must implement interface Traversable, array given

One code path that can cause this is https://gerrit.wikimedia.org/g/mediawiki/core/+/5f9e9f4e077ffe7b02c2b0236bd2dd61ee56074e/includes/TitleArray.php#48 (assuming hook modifies the input, but returns true instead of false). Like I wrote above, I did not find any usages of the hook.

So it must be https://gerrit.wikimedia.org/g/mediawiki/core/+/5f9e9f4e077ffe7b02c2b0236bd2dd61ee56074e/includes/Title.php#3538 then.

Basically a case of https://stackoverflow.com/questions/44587973/php-iterable-to-array-or-traversable where PHP is hostile towards functional style programming.

Most easily solved by replacing array_filter with a foreach loop.

Change 532789 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] Fix moving of translatable pages in namespaces without subpages

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

Change 532789 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Fix moving of translatable pages in namespaces without subpages

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

Assuming you mean wmf deployment branches... this bug has existed at least for 6 months. I see no reason to hurry with backports.

Nikerabbit renamed this task from Error moving translated category on Meta-Wiki to Error moving translated category (or any translatable page in a namespace without subpages enabled).Aug 30 2019, 6:46 AM