[go: up one dir, main page]

Page MenuHomePhabricator

importDump does not work with actor if the user name is not in canonical form
Closed, ResolvedPublic

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.


Analysis by Anomie, copied from the comments:
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.

Event Timeline

Paladox triaged this task as High priority.Dec 7 2018, 7:56 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>)

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.

Change 559027 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] User: better error message when getActorId fails.

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

Change 559029 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Importer: don't abort when revision insert fails

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

Change 559027 merged by jenkins-bot:
[mediawiki/core@master] User: better error message when getActorId fails.

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

Change 559948 had a related patch set uploaded (by Paladox; owner: Daniel Kinzler):
[mediawiki/core@REL1_34] User: better error message when getActorId fails.

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

Change 559948 merged by jenkins-bot:
[mediawiki/core@REL1_34] User: better error message when getActorId fails.

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

Is there any way to get around this issue? I'm currently trying to import an XML dump into a local MediaWiki install but getting this error.

daniel renamed this task from importDump does not work with actor if the user does not exist to importDump does not work with actor if the user name is not in canonical form.Jan 14 2020, 5:15 PM
daniel updated the task description. (Show Details)

Is there any way to get around this issue? I'm currently trying to import an XML dump into a local MediaWiki install but getting this error.

You can try to apply this patch: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/559029
That would cause the revision with the bad name to be skipped, but the import would continue.

Or you can try to edit the dump to fix the user name. If you don't know what the name is, try applying https://gerrit.wikimedia.org/r/559948

I'm not aware of another way to fix this, sorry.

@daniel I applied the patch but when trying to run the import I'm getting this error:

Wikimedia\Rdbms\DBTransactionStateError from line 1420 of C:\xampp\htdocs\mediawiki-134\includes\libs\rdbms\database\Database.php: Cannot execute query from WikiPage::pageData while transaction status is ERROR

EDIT: I just made a script to change out every <username>.*</username> to <username>admin</username> and it looks to be working.

Change 569644 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] ExternalUserNames: Handle otherwise-usable names with lowercase first letter

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

Change 569644 merged by jenkins-bot:
[mediawiki/core@master] ExternalUserNames: Handle otherwise-usable names with lowercase first letter

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

Change 570884 had a related patch set uploaded (by Paladox; owner: Anomie):
[mediawiki/core@REL1_34] ExternalUserNames: Handle otherwise-usable names with lowercase first letter

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

Just got an exception when I tried importing a Wikipedia XML:

CannotCreateActorException from line 2323 of /srv/mediawiki/w/includes/user/User.php: Cannot create an actor for a usable name that is not an existing user: user_id=0 user_name="Ჯუღაშვილი"
#0 /srv/mediawiki/w/includes/ActorMigration.php(303): User->getActorId(Object(Wikimedia\Rdbms\DatabaseMysqli))
#1 /srv/mediawiki/w/includes/Revision/RevisionStore.php(753): ActorMigration->getInsertValuesWithTempTable(Object(Wikimedia\Rdbms\DatabaseMysqli), 'rev_user', Object(User))
#2 /srv/mediawiki/w/includes/Revision/RevisionStore.php(552): MediaWiki\Revision\RevisionStore->insertRevisionRowOn(Object(Wikimedia\Rdbms\DatabaseMysqli), Object(MediaWiki\Revision\MutableRevisionRecord), Object(Title), 36599)
#3 /srv/mediawiki/w/includes/Revision/RevisionStore.php(490): MediaWiki\Revision\RevisionStore->insertRevisionInternal(Object(MediaWiki\Revision\MutableRevisionRecord), Object(Wikimedia\Rdbms\DatabaseMysqli), Object(User), Object(CommentStoreComment), Object(Title), 1155, 36599)
#4 /srv/mediawiki/w/includes/libs/rdbms/database/Database.php(3966): MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Object(Wikimedia\Rdbms\DatabaseMysqli), 'MediaWiki\\Revis...')
#5 /srv/mediawiki/w/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->doAtomicSection('MediaWiki\\Revis...', Object(Closure))
#6 /srv/mediawiki/w/includes/libs/rdbms/database/DBConnRef.php(635): Wikimedia\Rdbms\DBConnRef->__call('doAtomicSection', Array)
#7 /srv/mediawiki/w/includes/Revision/RevisionStore.php(498): Wikimedia\Rdbms\DBConnRef->doAtomicSection('MediaWiki\\Revis...', Object(Closure))
#8 /srv/mediawiki/w/includes/Revision.php(968): MediaWiki\Revision\RevisionStore->insertRevisionOn(Object(MediaWiki\Revision\MutableRevisionRecord), Object(Wikimedia\Rdbms\DBConnRef))
#9 /srv/mediawiki/w/includes/import/ImportableOldRevisionImporter.php(129): Revision->insertOn(Object(Wikimedia\Rdbms\DBConnRef))
#10 /srv/mediawiki/w/includes/import/WikiRevision.php(616): ImportableOldRevisionImporter->import(Object(WikiRevision))
#11 /srv/mediawiki/w/includes/import/WikiImporter.php(366): WikiRevision->importOldRevision()
#12 /srv/mediawiki/w/maintenance/importDump.php(209): WikiImporter->importRevision(Object(WikiRevision))
#13 /srv/mediawiki/w/includes/import/WikiImporter.php(501): BackupReader->handleRevision(Object(WikiRevision), Object(WikiImporter))
#14 /srv/mediawiki/w/includes/import/WikiImporter.php(941): WikiImporter->revisionCallback(Object(WikiRevision))
#15 /srv/mediawiki/w/includes/import/WikiImporter.php(860): WikiImporter->processRevision(Array, Array)
#16 /srv/mediawiki/w/includes/import/WikiImporter.php(802): WikiImporter->handleRevision(Array)
#17 /srv/mediawiki/w/includes/import/WikiImporter.php(606): WikiImporter->handlePage()
#18 /srv/mediawiki/w/maintenance/importDump.php(359): WikiImporter->doImport()
#19 /srv/mediawiki/w/maintenance/importDump.php(292): BackupReader->importFromHandle(Resource id #427)
#20 /srv/mediawiki/w/maintenance/importDump.php(127): BackupReader->importFromFile('/home/reception...')
#21 /srv/mediawiki/w/maintenance/doMaintenance.php(99): BackupReader->execute()
#22 /srv/mediawiki/w/maintenance/importDump.php(364): require_once('/srv/mediawiki/...')
#23 {main}

@Reception123 which version of mediawiki, exactly? The fix is in master (future 1.35) and in 1.34.1, but not in 1.34.0.

See also T251229: "Cannot create an actor for a usable name that is not an existing user" when importing revisions which also involves unusual Unicode characters (but not, as far as I can tell, lowercase names).

Marking as Resolved as it is in the Done column. Feel free to reopen if there is remaining work.

Change 570884 abandoned by Umherirrender:
[mediawiki/core@REL1_34] ExternalUserNames: Handle otherwise-usable names with lowercase first letter

Reason:
release is end of life

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