ILBFactory::getMainLB and ILoadBalancer::getConnectionRef both have an argument $domain which is a "Domain ID, or false for the current domain".
In existing code the wiki id often given as this argument, because wikiid and database name are often the same.
But when the current wikiid of the running wiki is passed to both functions a wrong database connection is returned and selecting expected tables from the local/running wiki does not work.
This affects extension with shared (central/global) tables under postgres. The postgres tests are failing with "relation does not exist", because test code often sets the shared database to the local one.
This only affects postgres when $wgDBmwschema is mediawiki (installer default). Setting a custom schema in postgres makes test pass.
There is a naming difference between a "wikiid" and a "database domain" and it seems also a semantical/conceptionally different.
The DatabaseDomain class described database/schema/prefix while the wikiid is handled in WikiMap class and described the database name (when the wiki was not renamed).
The schema and prefix part of the DatabaseDomain are null under mysql/sqlite and allows to use the wikiid and domain at the same location, but that does not work under postgres correctly.
There are functions to convert domain to wikiid (WikiMap:.getWikiIdFromDbDomain) or to create a domain (WikiMap::getCurrentWikiDbDomain)
In order to fix the postgres errors a check was added to convert the local wiki id to false to allow correct handling inside of Wikimedia\Rdbms to the following extensions:
- CentralAuth - T244899 / https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CentralAuth/+/812422
- BounceHandler - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/BounceHandler/+/815352
- OAuthRateLimiter - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/OAuthRateLimiter/+/815350
- Flow - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Flow/+/815800
- OAuth - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/OAuth/+/815349
I was asked from @Krinkle to create a task to get a look at it
Related is also some wikiid/domain check for the FileBackendGroup in the wiring code
// If the local wiki ID and local domain ID do not match, probably due to a non-default // schema, issue a warning. A non-default schema indicates that it might be used to // disambiguate different wikis. $legacyDomainId = strlen( $ld->getTablePrefix() ) ? "{$ld->getDatabase()}-{$ld->getTablePrefix()}" : $ld->getDatabase(); if ( $ld->getSchema() !== null && $legacyDomainId !== $fallbackWikiId ) { wfWarn( "Legacy default 'domainId' is '$legacyDomainId' but wiki ID is '$fallbackWikiId'." ); }
More related changes from the past: