Page MenuHomePhabricator

Fix broken FileImporter unit test
Closed, ResolvedPublic5 Story Points

Description

FileImporter tests are current failing due to the https://gerrit.wikimedia.org/r/501594 Default $wgActorTableSchemaMigrationStage to READ_NEW change in core.

The test imports file revisions with usernames that do not exist on the wiki using the ImportableUploadRevisionImporter

https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-hhvm-docker/44928/console

16:20:33 CannotCreateActorException: Cannot create an actor for a usable name that is not an existing user
16:20:33 
16:20:33 /workspace/src/includes/user/User.php:2520
16:20:33 /workspace/src/includes/filerepo/file/LocalFile.php:1462
16:20:33 /workspace/src/includes/filerepo/file/LocalFile.php:1375
16:20:33 /workspace/src/includes/import/ImportableUploadRevisionImporter.php:126
16:20:33 /workspace/src/extensions/FileImporter/src/Operations/FileRevisionFromRemoteUrl.php:182
16:20:33 /workspace/src/extensions/FileImporter/src/Data/ImportOperations.php:92
16:20:33 /workspace/src/extensions/FileImporter/src/Services/Importer.php:290
16:20:33 /workspace/src/extensions/FileImporter/src/Services/Importer.php:178
16:20:33 /workspace/src/extensions/FileImporter/src/Services/Importer.php:119
16:20:33 /workspace/src/extensions/FileImporter/tests/phpunit/Services/ImporterTest.php:85
16:20:33 /workspace/src/tests/phpunit/MediaWikiTestCase.php:427
16:20:33 /workspace/src/maintenance/doMaintenance.php:96

Event Timeline

Jdforrester-WMF renamed this task from Fix broken FileImpoter unit test to Fix broken FileImporter unit test.Apr 12 2019, 6:34 PM
Jdforrester-WMF added a subscriber: Jdforrester-WMF.

Change 503645 had a related patch set uploaded (by WMDE-Fisch; owner: WMDE-Fisch):
[mediawiki/extensions/FileImporter@master] Minor fix in the ImporterTest cleanup

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

Tests seems to be failing since https://gerrit.wikimedia.org/r/501594 Default $wgActorTableSchemaMigrationStage to READ_NEW. From the kind of change in that patch I assume this is somewhat related to the usernames on the imported revisions, that are non-existent when importing files.

The issue from the stack trace above can easily be fixed, since this is only related to file cleanup after the import and is only occurring because the import fails earlier. See the updated issue

WMDE-Fisch updated the task description. (Show Details)Apr 13 2019, 2:25 PM

Note: Currently this should not trigger any errors in production. There we run a hook in the preparation of the upload, that creates users locally via CentralAuth/SUL if they do not exist yet.

Change 504832 had a related patch set uploaded (by WMDE-Fisch; owner: WMDE-Fisch):
[mediawiki/extensions/FileImporter@master] Use prefixed external usernames when importing file revisions

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

WMDE-Fisch set the point value for this task to 5.
WMDE-Fisch moved this task from Sprint Backlog to Review on the WMDE-QWERTY-Sprint-2019-04-17 board.
WMDE-Fisch added a comment.EditedApr 18 2019, 12:44 PM

For the protocol here:

Fixing this test lead to another revelation: Prefixed user names are now working for imported FileRevisions so we can use them in cases where there is no local user found. For the current FileImporter in production this is not relevant, since we can always find a local user with the help of CentralAuth and SUL though.

Still the import logic for the import of file revisions needed to be adjusted to consider these new options in order to fix the failing tests.

tl;dr: Nothing changes for production, but if people use the FileImporter in a context where there's no CentralAuth, imported unknown usernames are prefixed now for text- and file revisions \o/

Change 504832 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Use prefixed external usernames when importing file revisions

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

Change 503645 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Minor fix in the ImporterTest cleanup

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

WMDE-Fisch closed this task as Resolved.May 8 2019, 4:24 PM