Page MenuHomePhabricator

Special:ImportTranslations says both "There were no changes for this language." and "Import complete!" (with a "PHP Warning: Invalid argument supplied for foreach() in MessageWebImporter.php:346")
Closed, ResolvedPublic

Description

Summary: Fixed a regression that broke web import of offline translations. Users got an incorrect message that claimed that their translations were imported, when they were not.

User report

When I import translation using Special:ImportTranslations, the page throws an error "There were no changes for this language. Use the link below to return to the group details view.", despite saying "Import complete!".

The translatewiki error log bot on irc says PHP Warning: Invalid argument supplied for foreach() in /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php on line 346.

This error can also happen if you upload a .po file that just been exported from translatewiki.

Log output

[2020-05-19 04:31:25] error.ERROR: [15de629e5ce30c97966cbdb8] /wiki/Special:ImportTranslations   ErrorException from line 89 of /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php: PHP Notice: Undefined index: MESSAGES {"exception":"[object] (ErrorException(code: 0): PHP Notice: Undefined index: MESSAGES at /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php:89)
[stacktrace]
#0 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php(89): MWExceptionHandler::handleError(8, 'Undefined index...', '/srv/mediawiki/...', 89, Array)
#1 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPage.php(576): SpecialImportTranslations->execute(NULL)
#2 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPageFactory.php(618): SpecialPage->run(NULL)
#3 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(299): MediaWiki\\SpecialPage\\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#4 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(973): MediaWiki->performRequest()
#5 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(535): MediaWiki->main()
#6 /srv/mediawiki/tags/2020-05-06_15:01:06/index.php(47): MediaWiki->run()
#7 {main}
","exception_id":"15de629e5ce30c97966cbdb8","exception_url":"/wiki/Special:ImportTranslations","caught_by":"mwe_handler"} []
[19-May-2020 04:31:25 UTC] PHP Notice:  Undefined index: MESSAGES in /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php on line 89
[2020-05-19 04:31:26] error.ERROR: [15de629e5ce30c97966cbdb8] /wiki/Special:ImportTranslations   ErrorException from line 214 of /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php: PHP Warning: Invalid argument supplied for foreach() {"exception":"[object] (ErrorException(code: 0): PHP Warning: Invalid argument supplied for foreach() at /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php:214)
[stacktrace]
#0 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php(214): MWExceptionHandler::handleError(2, 'Invalid argumen...', '/srv/mediawiki/...', 214, Array)
#1 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php(101): MessageWebImporter->execute(NULL)
#2 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPage.php(576): SpecialImportTranslations->execute(NULL)
#3 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPageFactory.php(618): SpecialPage->run(NULL)
#4 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(299): MediaWiki\\SpecialPage\\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#5 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(973): MediaWiki->performRequest()
#6 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(535): MediaWiki->main()
#7 /srv/mediawiki/tags/2020-05-06_15:01:06/index.php(47): MediaWiki->run()
#8 {main}
","exception_id":"15de629e5ce30c97966cbdb8","exception_url":"/wiki/Special:ImportTranslations","caught_by":"mwe_handler"} []
[19-May-2020 04:31:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php on line 214
[2020-05-19 04:31:26] error.ERROR: [15de629e5ce30c97966cbdb8] /wiki/Special:ImportTranslations   ErrorException from line 344 of /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php: PHP Warning: array_keys() expects parameter 1 to be array, null given {"exception":"[object] (ErrorException(code: 0): PHP Warning: array_keys() expects parameter 1 to be array, null given at /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php:344)
[stacktrace]
#0 [internal function]: MWExceptionHandler::handleError(2, 'array_keys() ex...', '/srv/mediawiki/...', 344, Array)
#1 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php(344): array_keys(NULL)
#2 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php(101): MessageWebImporter->execute(NULL)
#3 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPage.php(576): SpecialImportTranslations->execute(NULL)
#4 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPageFactory.php(618): SpecialPage->run(NULL)
#5 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(299): MediaWiki\\SpecialPage\\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#6 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(973): MediaWiki->performRequest()
#7 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(535): MediaWiki->main()
#8 /srv/mediawiki/tags/2020-05-06_15:01:06/index.php(47): MediaWiki->run()
#9 {main}
","exception_id":"15de629e5ce30c97966cbdb8","exception_url":"/wiki/Special:ImportTranslations","caught_by":"mwe_handler"} []
[19-May-2020 04:31:26 UTC] PHP Warning:  array_keys() expects parameter 1 to be array, null given in /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php on line 344
[2020-05-19 04:31:26] error.ERROR: [15de629e5ce30c97966cbdb8] /wiki/Special:ImportTranslations   ErrorException from line 344 of /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php: PHP Warning: array_diff(): Expected parameter 2 to be an array, null given {"exception":"[object] (ErrorException(code: 0): PHP Warning: array_diff(): Expected parameter 2 to be an array, null given at /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php:344)
[stacktrace]
#0 [internal function]: MWExceptionHandler::handleError(2, 'array_diff(): E...', '/srv/mediawiki/...', 344, Array)
#1 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php(344): array_diff(Array, NULL)
#2 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php(101): MessageWebImporter->execute(NULL)
#3 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPage.php(576): SpecialImportTranslations->execute(NULL)
#4 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPageFactory.php(618): SpecialPage->run(NULL)
#5 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(299): MediaWiki\\SpecialPage\\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#6 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(973): MediaWiki->performRequest()
#7 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(535): MediaWiki->main()
#8 /srv/mediawiki/tags/2020-05-06_15:01:06/index.php(47): MediaWiki->run()
#9 {main}
","exception_id":"15de629e5ce30c97966cbdb8","exception_url":"/wiki/Special:ImportTranslations","caught_by":"mwe_handler"} []
[19-May-2020 04:31:26 UTC] PHP Warning:  array_diff(): Expected parameter 2 to be an array, null given in /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php on line 344
[2020-05-19 04:31:26] error.ERROR: [15de629e5ce30c97966cbdb8] /wiki/Special:ImportTranslations   ErrorException from line 346 of /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php: PHP Warning: Invalid argument supplied for foreach() {"exception":"[object] (ErrorException(code: 0): PHP Warning: Invalid argument supplied for foreach() at /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php:346)
[stacktrace]
#0 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php(346): MWExceptionHandler::handleError(2, 'Invalid argumen...', '/srv/mediawiki/...', 346, Array)
#1 /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/specials/SpecialImportTranslations.php(101): MessageWebImporter->execute(NULL)
#2 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPage.php(576): SpecialImportTranslations->execute(NULL)
#3 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/specialpage/SpecialPageFactory.php(618): SpecialPage->run(NULL)
#4 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(299): MediaWiki\\SpecialPage\\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#5 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(973): MediaWiki->performRequest()
#6 /srv/mediawiki/tags/2020-05-06_15:01:06/includes/MediaWiki.php(535): MediaWiki->main()
#7 /srv/mediawiki/tags/2020-05-06_15:01:06/index.php(47): MediaWiki->run()
#8 {main}
","exception_id":"15de629e5ce30c97966cbdb8","exception_url":"/wiki/Special:ImportTranslations","caught_by":"mwe_handler"} []
[19-May-2020 04:31:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in /srv/mediawiki/tags/2020-05-06_15:01:06/extensions/Translate/utils/MessageWebImporter.php on line 346

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 18 2020, 4:03 PM

Hi @VulpesVulpes825, thanks for taking the time to report this! Unfortunately this Wikimedia Phabricator task lacks some information.
Can you please follow https://www.mediawiki.org/wiki/How_to_report_a_bug when creating tasks, and always provide

  • a clear list of exact steps to reproduce the situation, step by step, so that nobody needs to guess or interpret how you performed each step,
  • what happens after performing these steps to reproduce,
  • what you expected to happen instead,
  • a full link to a web address where the issue can be seen.

You can edit the task description by clicking Edit Task. Ideally, a good description should allow any other person to follow these steps (without having to interpret steps) and see the same results. Problems that others can reproduce can get fixed faster. We appreciate people who report issues, so thanks again!

Aklapper renamed this task from Import Translation broke line 346's foreach loop to Special:ImportTranslations says both "There were no changes for this language." and "Import complete!" (with a "PHP Warning: Invalid argument supplied for foreach() in MessageWebImporter.php:346").May 18 2020, 4:08 PM
Nikerabbit updated the task description. (Show Details)May 19 2020, 8:49 AM
Nikerabbit added a subscriber: Nikerabbit.

I think this is a regression from my recent refactoring.

Nikerabbit triaged this task as High priority.
Nikerabbit updated the task description. (Show Details)

Change 597280 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/Translate@master] Fix regression that broke offline import

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

Change 597280 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Fix regression that broke offline import

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

abi_ closed this task as Resolved.May 22 2020, 1:35 PM
abi_ moved this task from In Review to Done on the Language-Team (Language-2020-Focus-Sprint) board.
abi_ added a subscriber: abi_.

This has been deployed and tested on translatewiki.net.