Page MenuHomePhabricator

importDump.php stops with exception 'Cannot create an actor for a usable name that is not an existing user'
Closed, DuplicatePublic

Description

While trying to test T238043 with a script, I end up with this:

...
14200 (11.52 pages/sec 11.52 revs/sec)>                                      ] 22% ETA 1:12:18
14300 (11.52 pages/sec 11.52 revs/sec)>                                      ] 22% ETA 1:12:11
14400 (11.52 pages/sec 11.52 revs/sec)>                                      ] 22% ETA 1:11:58
CannotCreateActorException from line 2282 of /opt/htdocs/mediawiki/includes/user/User.php: Cannot create an actor for a usable name that is not an existing user
#0 /opt/htdocs/mediawiki/includes/ActorMigration.php(303): User->getActorId(Object(Wikimedia\Rdbms\DatabaseMysqli))
#1 /opt/htdocs/mediawiki/includes/Revision/RevisionStore.php(753): ActorMigration->getInsertValuesWithTempTable(Object(Wikimedia\Rdbms\DatabaseMysqli), 'rev_user', Object(User))
#2 /opt/htdocs/mediawiki/includes/Revision/RevisionStore.php(552): MediaWiki\Revision\RevisionStore->insertRevisionRowOn(Object(Wikimedia\Rdbms\DatabaseMysqli), Object(MediaWiki\Revision\MutableRevisionRecord), Object(Title), 0)
#3 /opt/htdocs/mediawiki/includes/Revision/RevisionStore.php(490): MediaWiki\Revision\RevisionStore->insertRevisionInternal(Object(MediaWiki\Revision\MutableRevisionRecord), Object(Wikimedia\Rdbms\DatabaseMysqli), Object(User), Object(CommentStoreComment), Object(Title), 14467, 0)
#4 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(3966): MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}(Object(Wikimedia\Rdbms\DatabaseMysqli), 'MediaWiki\\Revis...')
#5 /opt/htdocs/mediawiki/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->doAtomicSection('MediaWiki\\Revis...', Object(Closure))
#6 /opt/htdocs/mediawiki/includes/libs/rdbms/database/DBConnRef.php(635): Wikimedia\Rdbms\DBConnRef->__call('doAtomicSection', Array)
#7 /opt/htdocs/mediawiki/includes/Revision/RevisionStore.php(498): Wikimedia\Rdbms\DBConnRef->doAtomicSection('MediaWiki\\Revis...', Object(Closure))
#8 /opt/htdocs/mediawiki/includes/Revision.php(968): MediaWiki\Revision\RevisionStore->insertRevisionOn(Object(MediaWiki\Revision\MutableRevisionRecord), Object(Wikimedia\Rdbms\DBConnRef))
#9 /opt/htdocs/mediawiki/includes/import/ImportableOldRevisionImporter.php(129): Revision->insertOn(Object(Wikimedia\Rdbms\DBConnRef))
#10 /opt/htdocs/mediawiki/includes/import/WikiRevision.php(616): ImportableOldRevisionImporter->import(Object(WikiRevision))
#11 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(366): WikiRevision->importOldRevision()
#12 /opt/htdocs/mediawiki/maintenance/importDump.php(209): WikiImporter->importRevision(Object(WikiRevision))
#13 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(501): BackupReader->handleRevision(Object(WikiRevision), Object(WikiImporter))
#14 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(941): WikiImporter->revisionCallback(Object(WikiRevision))
#15 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(860): WikiImporter->processRevision(Array, Array)
#16 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(802): WikiImporter->handleRevision(Array)
#17 /opt/htdocs/mediawiki/includes/import/WikiImporter.php(606): WikiImporter->handlePage()
#18 /opt/htdocs/mediawiki/maintenance/importDump.php(359): WikiImporter->doImport()
#19 /opt/htdocs/mediawiki/maintenance/importDump.php(301): BackupReader->importFromHandle(Resource id #252)
#20 /opt/htdocs/mediawiki/maintenance/importDump.php(129): BackupReader->importFromStdin()
#21 /opt/htdocs/mediawiki/maintenance/doMaintenance.php(99): BackupReader->execute()
#22 /opt/htdocs/mediawiki/maintenance/importDump.php(364): require_once('/opt/htdocs/med...')
#23 {main}
[f2e33a53a89f4bbd09627f75] [no req]   Wikimedia\Rdbms\DBTransactionError from line 1680 of /opt/htdocs/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php: BackupReader: Commit failed on server(s) localhost: Cannot execute query from BackupReader while transaction status is ERROR
Backtrace:
#0 /opt/htdocs/mediawiki/includes/libs/rdbms/lbfactory/LBFactory.php(208): Wikimedia\Rdbms\LoadBalancer->commitMasterChanges(string, integer)
#1 /opt/htdocs/mediawiki/includes/libs/rdbms/lbfactory/LBFactorySimple.php(134): Wikimedia\Rdbms\LBFactory->Wikimedia\Rdbms\{closure}(Wikimedia\Rdbms\LoadBalancer, string, array)
#2 /opt/htdocs/mediawiki/includes/libs/rdbms/lbfactory/LBFactory.php(210): Wikimedia\Rdbms\LBFactorySimple->forEachLB(Closure, array)
#3 /opt/htdocs/mediawiki/includes/libs/rdbms/lbfactory/LBFactory.php(273): Wikimedia\Rdbms\LBFactory->forEachLBCallMethod(string, array)
#4 /opt/htdocs/mediawiki/maintenance/doMaintenance.php(124): Wikimedia\Rdbms\LBFactory->commitMasterChanges(string)
#5 /opt/htdocs/mediawiki/maintenance/importDump.php(364): require_once(string)
#6 {main}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 12 2019, 8:57 PM
MarkAHershberger renamed this task from importDump.php with `--no-local-users stops` with exception 'Cannot create an actor for a usable name that is not an existing user' to importDump.php with --no-local-users stops with exception 'Cannot create an actor for a usable name that is not an existing user'.Nov 12 2019, 9:00 PM
MarkAHershberger renamed this task from importDump.php with --no-local-users stops with exception 'Cannot create an actor for a usable name that is not an existing user' to importDump.php stops with exception 'Cannot create an actor for a usable name that is not an existing user'.Nov 12 2019, 9:41 PM
MarkAHershberger updated the task description. (Show Details)

Originally, I thought this was becaue of the --no-local-users flag, but now I'm able to reproduce it consistently, even with --skip-to=14400.

Trying to reproduce with a fairly plain LocalSettings.php.

What's the value of <username> for the revision that's failing? I wouldn't be surprised if this turns out to be something similar to T211450#4811373.

var_dump shows

object(User)#215 (35) {
  ["mId"]=>
  int(0)
  ["mName"]=>
  string(15) "Გამაგ"
  ["mActorId":protected]=>
  NULL

the revision is 14466 in that dump.

MarkAHershberger added a comment.EditedNov 12 2019, 10:25 PM

sorry about that, I have a better version here: გამაგ from this revision.

The first comment's [[ https://phabricator.wikimedia.org/T238149#5658509 | var_dump ]] was done just before this line. At that point, both $this->mName and $q['actor_name'] contained the malformed username: "Გამაგ"

The next comment's user name was from WikiRevision->user_text at WikiRevision::importOldRevision().

Found the culprit!

This code calls User::newFromName() on "გამაგ" and returns a user named "Გამაგ".

This happens because User::getCanonicalName() uses MediaWikiServices::getInstance()->getContentLanguage() to get a LanguageEn object and Language::uc() recognises a multibyte string so passes it to Language::mbUpperChar() which paasses it to mb_strtoupper().

Incidently, I should have tried my test to see if a character that I don't have a font for (Გ) is valid by visiting https://en.wikipedia.org/wiki/Გ initially. I would have seen that, yes, this is a valid Georgian letter.

So, why does my installation of MediaWiki fail on this? Maybe I should have an up-to-date cldr?

So, why does my installation of MediaWiki fail on this?

You are presumably using PHP 7.3+, which uses Unicode 11 for mbstring functions. You're running into a problem similar to that described at T219279: Some pages will become completely unreachable after PHP7 update due to Unicode changes, that name is considered valid in PHP 7.2 (Unicode 10) and earlier, but is no longer valid under Unicode 11 as that version of Unicode now considers to be a lowercase letter.

The specific error here is the same as T211450#4811373, where the dump importing is checking a non-canonicalized version of the username.

So that future me (when I get my fonts fixed) or someone else looking at this doesn't get too confused, here is the tofu I see for the relevent parts of this comment: