X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FWikiMap.php;h=23b0e3edb20cd0e3edeeb010a54d40ddbd1b7138;hb=f01c8c59fd6387aac1e331fe4ba23604e7e94737;hp=8b000f2063b283aef4b28664211f498c9b922ff1;hpb=a38af7ba26579bb3004f673e44d39710887763aa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WikiMap.php b/includes/WikiMap.php index 8b000f2063..23b0e3edb2 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -221,19 +221,29 @@ class WikiMap { * @since 1.30 */ public static function getWikiFromUrl( $url ) { + global $wgCanonicalServer; + + if ( strpos( $url, "$wgCanonicalServer/" ) === 0 ) { + // Optimisation: Handle the the common case. + // (Duplicates self::getCanonicalServerInfoForAllWikis) + return self::getWikiIdFromDbDomain( self::getCurrentWikiDbDomain() ); + } + $urlPartsCheck = wfParseUrl( $url ); if ( $urlPartsCheck === false ) { return false; } - $urlPartsCheck = array_intersect_key( $urlPartsCheck, [ 'host' => 1, 'port' => 1 ] ); + static $relevantKeys = [ 'host' => 1, 'port' => 1 ]; + $urlPartsCheck = array_intersect_key( $urlPartsCheck, $relevantKeys ); + foreach ( self::getCanonicalServerInfoForAllWikis() as $wikiId => $info ) { $urlParts = $info['parts']; if ( $urlParts === false ) { continue; // sanity } - $urlParts = array_intersect_key( $urlParts, [ 'host' => 1, 'port' => 1 ] ); + $urlParts = array_intersect_key( $urlParts, $relevantKeys ); if ( $urlParts == $urlPartsCheck ) { return $wikiId; }