X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWikiMap.php;h=f7b8d2f16dfa0c7517124e0e693c1fb30db668ab;hb=e3f89572a19400de0f18e714cb9ca8aaa0c0cfaa;hp=4534414c9f7c7be71df7319b94bf12ff728332cc;hpb=f9128d21b70e1a960f247f5af92af528f027d6a4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WikiMap.php b/includes/WikiMap.php index 4534414c9f..f7b8d2f16d 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 @@ -138,7 +141,7 @@ class WikiMap { * @param string $wikiID Wiki'd id (generally database name) * @param string $page Page name (must be normalised before calling this function!) * @param string $text Link's text; optional, default to $page - * @return string HTML link or false if the wiki was not found + * @return string|false HTML link or false if the wiki was not found */ public static function makeForeignLink( $wikiID, $page, $text = null ) { if ( !$text ) {