Page MenuHomePhabricator

Survey cross-wiki User object creation and replace with ActorStore
Open, HighPublic


Currently sometimes we could pass around Users from other wikis, and we sometimes can create actors for such users in the actor table. This problem for actor table will occur with User::getActorId calls with a IDatabase connection to another wiki. Replacing that with calling ActorStore::acquireActorId on the store matching the wikiId should in theory fix this issue and allow us to start enforcing wikiId in ActorStore

Event Timeline

It's hard to identify code that constructs a User object on a name or ID that doesn't belong to the local wiki. The issue that caused T260485 is such a case. Basically, DatabaseBlock tries to be agnostic about what wiki the user belongs to, but doesn't quite succeed. CentralAuthUser assumes DatabaseBlock will work with a cross-wiki DB connection. Which it kind of does at the moment, but the situation is very brittle. I filed T274817: Convert DatabaseBlock and AbstractBlock to UserIdentity, and make them cross-wiki aware. for fixing it.

I found three places where User::newFromRow is used to create a User on data from another wiki:

  • WikimediaMaintenance: unsuppressCrossWiki.php
  • WikimediaMaintenance: renameInvalidUsernames.php
  • Echo: BackfillUnreadWikis

Heh, so this is actually pretty interesting. for unsuppressCrossWiki.php we can't actually just replace things with ActorStore - that will actually break it. The user created from a foreign DB row is then used with ActorMigration which is oblivious to the DB domain, so if we replace User with UserIdentity referencing a proper wiki there, we will immediately explode on actor migration assuming it's a local wiki.

However, this is actually not a blocker for ActorStore - ActorStore is never used for the users created in an invalid way.

Change 682963 had a related patch set uploaded (by Ppchelko; author: Ppchelko):

[mediawiki/core@master] Deprecate passing invalid cross-wiki User to ActorStore

Change 682963 merged by jenkins-bot:

[mediawiki/core@master] Deprecate passing invalid cross-wiki User to ActorStore

Change 808041 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/extensions/WikimediaMaintenance@master] renameInvalidUserNames: Stop creating User objects cross-wiki

Change 808041 abandoned by Zabe:

[mediawiki/extensions/WikimediaMaintenance@master] renameInvalidUsernames: Stop creating User objects cross-wiki