To allow service objects for safe cross-wiki operations, we need t make all entity objects aware of which wiki they belong to. UserIdentity is so far lacking this information.
Similar to what we do with PageIdentity (and soon with RevisionRecord), UserIdentity should get the following methods:
public function getWikiId: string|false; public function assertWiki( string|false $wikiId );
And methods that return IDs that are bound to specific databases need to assert the wikiId:
public function getUserId( $wikiId = self::LOCAL ): int; public function getActorId( $wikiId = self::LOCAL ): int;
For backwards compatibility, calls getActorId() with no $wikiId provided should not yet fail if the user belongs to another wiki, but merely trigger a deprecation warning. The getId() emthod should be deprecated, and should emit deprecation warnings when called on an instance that belongs to another wiki.
- add wiki ID to UserIdentity
- make getId(), getUserId() and getActorId() trigger a warning if $wikiId is LOCAL but the object belongs to another wiki. If $wikiId is provided but mismatches, throw.
- after ensuring the above deprecations do not cause problems, make getUserId() and getActorId() always throw if $wikiId mismatches, and remove getId().
- getId() should at some point be renamed to getUserId() for clarity. If we do it now, getUserId() could immediately throw on mismatching $wikiId.
- It should probably not be possible for a UserIdentity to have a user ID but no actor ID. If a user ID is given, an actor ID must also be given, I think. There may however be existing tests that don't follow that rule.