Page MenuHomePhabricator

importDump does not work with actor if the user does not exist
Open, HighPublic

Description

Hi, when i tried to import a dump (with users that do not exist in that wiki) it causes a actor exception:

[235f86487b2e1d444e16276f] [no req]   CannotCreateActorException from line 2456 of /srv/mediawiki/w/includes/user/User.php: Cannot create an actor for a usable name that is not an existing user
Backtrace:
#0 /srv/mediawiki/w/includes/ActorMigration.php(245): User->getActorId(Wikimedia\Rdbms\DBConnRef)
#1 /srv/mediawiki/w/includes/Storage/RevisionStore.php(426): ActorMigration->getInsertValuesWithTempTable(Wikimedia\Rdbms\DBConnRef, string, User)
#2 /srv/mediawiki/w/includes/Revision.php(1123): MediaWiki\Storage\RevisionStore->insertRevisionOn(MediaWiki\Storage\MutableRevisionRecord, Wikimedia\Rdbms\DBConnRef)
#3 /srv/mediawiki/w/includes/import/ImportableOldRevisionImporter.php(129): Revision->insertOn(Wikimedia\Rdbms\DBConnRef)
#4 /srv/mediawiki/w/includes/import/WikiRevision.php(602): ImportableOldRevisionImporter->import(WikiRevision)
#5 /srv/mediawiki/w/includes/import/WikiImporter.php(366): WikiRevision->importOldRevision()
#6 /srv/mediawiki/w/maintenance/importDump.php(196): WikiImporter->importRevision(WikiRevision)
#7 /srv/mediawiki/w/includes/import/WikiImporter.php(503): BackupReader->handleRevision(WikiRevision, WikiImporter)
#8 /srv/mediawiki/w/includes/import/WikiImporter.php(943): WikiImporter->revisionCallback(WikiRevision)
#9 /srv/mediawiki/w/includes/import/WikiImporter.php(859): WikiImporter->processRevision(array, array)
#10 /srv/mediawiki/w/includes/import/WikiImporter.php(801): WikiImporter->handleRevision(array)
#11 /srv/mediawiki/w/includes/import/WikiImporter.php(608): WikiImporter->handlePage()
#12 /srv/mediawiki/w/maintenance/importDump.php(345): WikiImporter->doImport()
#13 /srv/mediawiki/w/maintenance/importDump.php(278): BackupReader->importFromHandle(resource)
#14 /srv/mediawiki/w/maintenance/importDump.php(114): BackupReader->importFromFile(string)
#15 /srv/mediawiki/w/maintenance/doMaintenance.php(94): BackupReader->execute()
#16 /srv/mediawiki/w/maintenance/importDump.php(350): require_once(string)
#17 {main}

This should be fixed to work again.

Event Timeline

Paladox created this task.Dec 7 2018, 7:55 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 7 2018, 7:55 PM
Paladox triaged this task as High priority.Dec 7 2018, 7:56 PM
Paladox reopened this task as Open.Dec 7 2018, 8:27 PM

Different problem to the one i merged it into.

[20:40:55] <paladox> i think it's because of "dial-xxx-x-xxx-xx.netcologne.de"
[20:41:13] <paladox> that was someone's id (in <username></username>)

Anomie added a comment.Dec 7 2018, 8:51 PM

You'll need to do some debugging to figure out why it's getting to that point without having prefixed the username.

Relaying from IRC: It turns out the problem is because the <username> is containing a name with a lowercased first letter. That fails the isUsableName() check when https://github.com/wikimedia/mediawiki/blob/REL1_31/includes/user/ExternalUserNames.php#L76 is called. But the name gets canonicalized by the time it makes it to https://github.com/wikimedia/mediawiki/blob/REL1_31/includes/user/User.php#L2455.

That's probably the wrong thing to do, though. If there's a valid case for the import to contain non-canonical usernames, they should probably be canonicalized before being passed to ExternalUserNames in the first place.

This comment was removed by MarkAHershberger.
This comment was removed by MarkAHershberger.