X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWikiMap.php;h=37f85ea27c1a6acd9ac712038145914b2d446a1a;hb=1cdd4682ed43ffe4d95597e54836189ca974404b;hp=dca0f32697b0f72794751a8cb286f275c617b34c;hpb=9ba3fca2d8adc56787c8efc32c41424cb212e387;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WikiMap.php b/includes/WikiMap.php index dca0f32697..37f85ea27c 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -65,6 +65,14 @@ class WikiMap { $path = $wgConf->get( 'wgArticlePath', $wikiID, $major, [ 'lang' => $minor, 'site' => $major ] ); + + // If we don't have a canonical server or a path containing $1, the + // WikiReference isn't going to function properly. Just return null in + // that case. + if ( !is_string( $canonicalServer ) || !is_string( $path ) || strpos( $path, '$1' ) === false ) { + return null; + } + return new WikiReference( $canonicalServer, $path, $server ); } @@ -73,13 +81,8 @@ class WikiMap { * @return WikiReference|null WikiReference object or null if the wiki was not found */ private static function getWikiWikiReferenceFromSites( $wikiID ) { - static $siteStore = null; - if ( !$siteStore ) { - // Replace once T114471 got fixed and don't do the caching here. - $siteStore = SiteSQLStore::newInstance(); - } - - $site = $siteStore->getSite( $wikiID ); + $siteLookup = \MediaWiki\MediaWikiServices::getInstance()->getSiteLookup(); + $site = $siteLookup->getSite( $wikiID ); if ( !$site instanceof MediaWikiSite ) { // Abort if not a MediaWikiSite, as this is about Wikis @@ -221,10 +224,10 @@ class WikiReference { * @return string relative URL, without the server part. */ private function getLocalUrl( $page, $fragmentId = null ) { - $page = wfUrlEncode( str_replace( ' ', '_', $page ) ); + $page = wfUrlencode( str_replace( ' ', '_', $page ) ); if ( is_string( $fragmentId ) && $fragmentId !== '' ) { - $page .= '#' . wfUrlEncode( $fragmentId ); + $page .= '#' . wfUrlencode( $fragmentId ); } return str_replace( '$1', $page, $this->mPath );