X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FWikiMap.php;h=8bb37b5c882a7a599d63ab658cdaa4a5bfc80a88;hp=4f3c461699faf148342019f4cd387f6d87e8796b;hb=a7064a0883ec6d715c8c8103efe777769a85437d;hpb=1d7a1bf8bddf0908e4f572c82268733f63126a13 diff --git a/includes/WikiMap.php b/includes/WikiMap.php index 4f3c461699..8bb37b5c88 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -21,6 +21,7 @@ */ use MediaWiki\MediaWikiServices; +use Wikimedia\Rdbms\DatabaseDomain; /** * Helper tools for dealing with other locally-hosted wikis. @@ -239,4 +240,22 @@ class WikiMap { return false; } + + /** + * Get the wiki ID of a database domain + * + * This is like DatabaseDomain::getId() without encoding (for legacy reasons) + * + * @param string|DatabaseDomain $domain + * @return string + */ + public static function getWikiIdFromDomain( $domain ) { + if ( !( $domain instanceof DatabaseDomain ) ) { + $domain = DatabaseDomain::newFromId( $domain ); + } + + return strlen( $domain->getTablePrefix() ) + ? "{$domain->getDatabase()}-{$domain->getTablePrefix()}" + : $domain->getDatabase(); + } }