Page MenuHomePhabricator

importDump.php failing on file uploads without --username-prefix="" set
Open, Needs TriagePublic

Description

When attempting to transfer the entire history of a couple of files from one wiki to another using dumpBackup.php and importDump.php I am getting the following error:

TypeError from line 193 of /opt/htdocs/mediawiki/includes/ActorMigration.php: Argument 3 passed to ActorMigration::getInsertValues() must implement interface MediaWiki\User\UserIdentity, boolean given, called in /opt/htdocs/mediawiki/includes/filerepo/file/OldLocalFile.php on line 450

Environment:

  • MediaWiki 1.31.1 (a4c8065)
  • PHP 7.0.32 (apache2handler)
  • MariaDB 5.5.60-MariaDB
  • ICU: 50.1.2
  • Elasticsearch 5.6.12

To setup which files to import, I do:

cd /opt/htdocs
echo "File:File1.docx" > somefiles
echo "File:File2.docx" >> somefiles

Then I run the following:

# From the first wiki get files:
php dumpBackup.php --full --logs --uploads --include-files --pagelist=/opt/htdocs/somefiles > /opt/htdocs/somefiles.xml

# Into the destination wiki import files:
php importDump.php --no-updates --uploads --debug --report=100 < /opt/htdocs/somefiles.xml

I've used this method in the past to import 1000s of files without issue, though not on MediaWiki 1.31. I've been able to work around this problem for these files by adding --username-prefix="" to the importDump.php command. In includes\import\ImportableUploadRevisionImporter.php on line 88, the value of $importableRevision->getUser() is imported>ActualUserName. By setting username-prefix I'm able to remove that imported> part.

I've attempted this on one file that I know imported properly in late June 2018, using MediaWiki 1.27. I'm getting a different error that seems to have the same cause:

Error from line 1447 of /opt/htdocs/mediawiki/includes/filerepo/file/LocalFile.php: Call to a member function getId() on boolean

Again, adding --username-prefix="" fixes this issue.

Note that I'm also getting the following error, which does not go away with the addition of username-prefix in either case:

Warning: XMLReader::open(): Unable to open source data in /opt/htdocs/mediawiki/includes/libs/mime/XmlTypeCheck.php on line 158

Full output of failing command on first set of files:

Warning: XMLReader::open(): Unable to open source data in /opt/htdocs/mediawiki/includes/libs/mime/XmlTypeCheck.php on line 158

[42a9e4327b9e9efbe58bc962] [no req]   TypeError from line 193 of /opt/htdocs/mediawiki/includes/ActorMigration.php: Argument 3 passed to ActorMigration::getInsertValues() must implement interface MediaWiki\User\UserIdentity, boolean given, called in /opt/htdocs/mediawiki/includes/filerepo/file/OldLocalFile.php on line 450
Backtrace:
#0 /opt/htdocs/mediawiki/includes/filerepo/file/OldLocalFile.php(450): ActorMigration->getInsertValues(Wikimedia\Rdbms\DatabaseMysqli, string, boolean)
#1 /opt/htdocs/mediawiki/includes/filerepo/file/OldLocalFile.php(420): OldLocalFile->recordOldUpload(string, string, string, string, boolean)
#2 /opt/htdocs/mediawiki/includes/import/ImportableUploadRevisionImporter.php(93): OldLocalFile->uploadOld(string, string, string, string, boolean)
#3 /opt/htdocs/mediawiki/includes/import/WikiRevision.php(659): ImportableUploadRevisionImporter->import(WikiRevision)
#4 [internal function]: WikiRevision->importUpload()
#5 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(3191): call_user_func_array(array, array)
#6 /opt/htdocs/mediawiki/maintenance/importDump.php(218): Wikimedia\Rdbms\Database->deadlockLoop(array)
#7 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(1049): BackupReader->handleUpload(WikiRevision)
#8 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(997): WikiImporter->processUpload(array, array)
#9 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(803): WikiImporter->handleUpload(array)
#10 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(608): WikiImporter->handlePage()
#11 /opt/htdocs/mediawiki/maintenance/importDump.php(345): WikiImporter->doImport()
#12 /opt/htdocs/mediawiki/maintenance/importDump.php(287): BackupReader->importFromHandle(resource)
#13 /opt/htdocs/mediawiki/maintenance/importDump.php(116): BackupReader->importFromStdin()
#14 /opt/htdocs/mediawiki/maintenance/doMaintenance.php(94): BackupReader->execute()
#15 /opt/htdocs/mediawiki/maintenance/importDump.php(350): require_once(string)
#16 {main}

Full output of failing command on second file (that had worked in June on MW 1.27):

Warning: XMLReader::open(): Unable to open source data in /opt/htdocs/mediawiki/includes/libs/mime/XmlTypeCheck.php on line 161
[d92bb55fab1f9898753d1fab] [no req]   Error from line 1447 of /opt/htdocs/mediawiki/includes/filerepo/file/LocalFile.php: Call to a member function getId() on boolean
Backtrace:
#0 /opt/htdocs/mediawiki/includes/filerepo/file/LocalFile.php(1364): LocalFile->recordUpload2(string, string, string, array, string, boolean, array)
#1 /opt/htdocs/mediawiki/includes/import/ImportableUploadRevisionImporter.php(114): LocalFile->upload(string, string, string, integer, array, string, boolean)
#2 /opt/htdocs/mediawiki/includes/import/WikiRevision.php(659): ImportableUploadRevisionImporter->import(WikiRevision)
#3 [internal function]: WikiRevision->importUpload()
#4 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(3191): call_user_func_array(array, array)
#5 /opt/htdocs/mediawiki/maintenance/importDump.php(218): Wikimedia\Rdbms\Database->deadlockLoop(array)
#6 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(1049): BackupReader->handleUpload(WikiRevision)
#7 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(997): WikiImporter->processUpload(array, array)
#8 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(803): WikiImporter->handleUpload(array)
#9 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(608): WikiImporter->handlePage()
#10 /opt/htdocs/mediawiki/maintenance/importDump.php(345): WikiImporter->doImport()
#11 /opt/htdocs/mediawiki/maintenance/importDump.php(287): BackupReader->importFromHandle(resource)
#12 /opt/htdocs/mediawiki/maintenance/importDump.php(116): BackupReader->importFromStdin()
#13 /opt/htdocs/mediawiki/maintenance/doMaintenance.php(94): BackupReader->execute()
#14 /opt/htdocs/mediawiki/maintenance/importDump.php(350): require_once(string)
#15 {main}

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 10 2018, 5:38 PM

Added note about possibly needing --username-prefix="" to docs: https://www.mediawiki.org/wiki/Manual:ImportDump.php