X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FWikiMap.php;h=3305f9f7d3ad9bf095ff97686ae14aeffd5fda56;hb=51945dbca3594;hp=b731d7bd957d2b63e11ff59a63100a885adbec23;hpb=d917159e0d638dbc3bcbd7e2e733c43af629d1bc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WikiMap.php b/includes/WikiMap.php index b731d7bd95..3305f9f7d3 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -246,6 +246,7 @@ class WikiMap { * Get the wiki ID of a database domain * * This is like DatabaseDomain::getId() without encoding (for legacy reasons) + * and without the schema if it merely set to the generic value "mediawiki" * * @param string|DatabaseDomain $domain * @return string @@ -253,9 +254,19 @@ class WikiMap { public static function getWikiIdFromDomain( $domain ) { $domain = DatabaseDomain::newFromId( $domain ); + if ( !in_array( $domain->getSchema(), [ null, 'mediawiki' ], true ) ) { + // Include the schema if it is set and is not the default placeholder. + // This means a site admin may have specifically taylored the schemas. + // Domain IDs might use the form --, meaning that + // the schema portion must be accounted for to disambiguate wikis. + return "{$domain->getDatabase()}-{$domain->getSchema()}-{$domain->getTablePrefix()}"; + } + + // Note that if this wiki ID is passed a a domain ID to LoadBalancer, then it can + // handle the schema by assuming the generic "mediawiki" schema if needed. return strlen( $domain->getTablePrefix() ) ? "{$domain->getDatabase()}-{$domain->getTablePrefix()}" - : $domain->getDatabase(); + : (string)$domain->getDatabase(); } /** @@ -277,9 +288,16 @@ class WikiMap { $domain = DatabaseDomain::newFromId( $domain ); $curDomain = self::getCurrentWikiDomain(); + if ( !in_array( $curDomain->getSchema(), [ null, 'mediawiki' ], true ) ) { + // Include the schema if it is set and is not the default placeholder. + // This means a site admin may have specifically taylored the schemas. + // Domain IDs might use the form --, meaning that + // the schema portion must be accounted for to disambiguate wikis. + return $curDomain->equals( $domain ); + } + return ( $curDomain->getDatabase() === $domain->getDatabase() && - // @TODO: check schema instead of assuming it's ""/"mediawiki" and never collides $curDomain->getTablePrefix() === $domain->getTablePrefix() ); }