Use WikiMap methods in ClassicInterwikiLookup instead of wfWikiId()
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 21 Oct 2018 07:02:11 +0000 (00:02 -0700)
committerKrinkle <krinklemail@gmail.com>
Mon, 29 Oct 2018 22:01:50 +0000 (22:01 +0000)
Change-Id: Ia3d843c79fa31fec59a04b92f4619458ae06de62

includes/interwiki/ClassicInterwikiLookup.php

index cdf4cde..f6265f7 100644 (file)
@@ -27,6 +27,7 @@ use Cdb\Reader as CdbReader;
 use Hooks;
 use Interwiki;
 use Language;
+use WikiMap;
 use MapCacheLRU;
 use WANObjectCache;
 use Wikimedia\Rdbms\Database;
@@ -212,17 +213,20 @@ class ClassicInterwikiLookup implements InterwikiLookup {
         */
        private function getInterwikiCacheEntry( $prefix ) {
                wfDebug( __METHOD__ . "( $prefix )\n" );
+
+               $wikiId = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+
                $value = false;
                try {
                        // Resolve site name
                        if ( $this->interwikiScopes >= 3 && !$this->thisSite ) {
-                               $this->thisSite = $this->getCacheValue( '__sites:' . wfWikiID() );
+                               $this->thisSite = $this->getCacheValue( '__sites:' . $wikiId );
                                if ( $this->thisSite == '' ) {
                                        $this->thisSite = $this->fallbackSite;
                                }
                        }
 
-                       $value = $this->getCacheValue( wfWikiID() . ':' . $prefix );
+                       $value = $this->getCacheValue( $wikiId . ':' . $prefix );
                        // Site level
                        if ( $value == '' && $this->interwikiScopes >= 3 ) {
                                $value = $this->getCacheValue( "_{$this->thisSite}:{$prefix}" );
@@ -334,11 +338,14 @@ class ClassicInterwikiLookup implements InterwikiLookup {
         */
        private function getAllPrefixesCached( $local ) {
                wfDebug( __METHOD__ . "()\n" );
+
+               $wikiId = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+
                $data = [];
                try {
                        /* Resolve site name */
                        if ( $this->interwikiScopes >= 3 && !$this->thisSite ) {
-                               $site = $this->getCacheValue( '__sites:' . wfWikiID() );
+                               $site = $this->getCacheValue( '__sites:' . $wikiId );
 
                                if ( $site == '' ) {
                                        $this->thisSite = $this->fallbackSite;
@@ -357,7 +364,7 @@ class ClassicInterwikiLookup implements InterwikiLookup {
                        if ( $this->interwikiScopes >= 3 ) {
                                $sources[] = '_' . $this->thisSite;
                        }
-                       $sources[] = wfWikiID();
+                       $sources[] = $wikiId;
 
                        foreach ( $sources as $source ) {
                                $list = $this->getCacheValue( '__list:' . $source );