jenkins-bot has submitted this change and it was merged.

Change subject: Don't load all sites for LangLinkHandler
......................................................................


Don't load all sites for LangLinkHandler

Change-Id: I9e6de257f32dab6d49de5852f56dfba7a182994c
(cherry picked from commit 8c91cfb472f0ade7871917d6ab7e418b144ea63a)
---
M client/includes/LangLinkHandler.php
M client/includes/WikibaseClient.php
M client/tests/phpunit/includes/LangLinkHandlerTest.php
M client/tests/phpunit/includes/hooks/ParserAfterParserHookHandlerTest.php
4 files changed, 19 insertions(+), 18 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/client/includes/LangLinkHandler.php 
b/client/includes/LangLinkHandler.php
index 0cb47ab..176aaa2 100644
--- a/client/includes/LangLinkHandler.php
+++ b/client/includes/LangLinkHandler.php
@@ -4,12 +4,11 @@
 
 use ParserOutput;
 use Site;
-use SiteList;
+use SiteStore;
 use Title;
 use Wikibase\Client\Hooks\LanguageLinkBadgeDisplay;
 use Wikibase\Client\Hooks\OtherProjectsSidebarGeneratorFactory;
 use Wikibase\Client\Usage\ParserOutputUsageAccumulator;
-use Wikibase\DataModel\Entity\Item;
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\SiteLink;
 use Wikibase\Lib\Store\EntityLookup;
@@ -59,9 +58,9 @@
        private $entityLookup;
 
        /**
-        * @var SiteList
+        * @var SiteStore
         */
-       private $sites;
+       private $siteStore;
 
        /**
         * @var string
@@ -80,7 +79,7 @@
         * @param NamespaceChecker $namespaceChecker determines which 
namespaces wikibase is enabled on
         * @param SiteLinkLookup $siteLinkLookup A site link lookup service
         * @param EntityLookup $entityLookup An entity lookup service
-        * @param SiteList $sites
+        * @param SiteStore $sites
         * @param string $siteGroup The ID of the site group to use for showing 
language links.
         */
        public function __construct(
@@ -90,7 +89,7 @@
                NamespaceChecker $namespaceChecker,
                SiteLinkLookup $siteLinkLookup,
                EntityLookup $entityLookup,
-               SiteList $sites,
+               SiteStore $sites,
                $siteGroup
        ) {
                $this->otherProjectsSidebarGeneratorFactory = 
$otherProjectsSidebarGeneratorFactory;
@@ -99,7 +98,7 @@
                $this->namespaceChecker = $namespaceChecker;
                $this->siteLinkLookup = $siteLinkLookup;
                $this->entityLookup = $entityLookup;
-               $this->sites = $sites;
+               $this->siteStore = $sites;
                $this->siteGroup = $siteGroup;
        }
 
@@ -175,7 +174,7 @@
 
                foreach ( $links as $link ) {
                        $siteId = $link->getSiteId();
-                       $site = $this->sites->getSite( $siteId );
+                       $site = $this->siteStore->getSite( $siteId );
 
                        if ( !$site ) {
                                continue;
@@ -253,8 +252,9 @@
                                return array();
                        }
 
-                       if ( $this->sites->hasNavigationId( $code ) ) {
-                               $site = $this->sites->getSiteByNavigationId( 
$code );
+                       $sites = $this->siteStore->getSites();
+                       if ( $sites->hasNavigationId( $code ) ) {
+                               $site = $sites->getSiteByNavigationId( $code );
                                $wiki = $site->getGlobalId();
                                unset( $repoLinks[$wiki] );
                        }
@@ -282,14 +282,14 @@
                wfProfileIn( __METHOD__ );
 
                foreach ( $repoLinks as $wiki => $link ) {
-                       if ( !$this->sites->hasSite( $wiki ) ) {
+                       if ( !$this->siteStore->getSite( $wiki ) ) {
                                wfDebugLog( __CLASS__, __FUNCTION__ . ': 
skipping link to unknown site ' . $wiki );
 
                                unset( $repoLinks[$wiki] );
                                continue;
                        }
 
-                       $site = $this->sites->getSite( $wiki );
+                       $site = $this->siteStore->getSite( $wiki );
 
                        if ( !in_array( $site->getGroup(), $allowedGroups ) ) {
                                wfDebugLog( __CLASS__, __FUNCTION__ . ': 
skipping link to other group: ' . $wiki
@@ -340,8 +340,9 @@
                                $lang = $parts[0];
                                $page = $parts[1];
 
-                               if ( $this->sites->hasNavigationId( $lang ) ) {
-                                       $site = 
$this->sites->getSiteByNavigationId( $lang );
+                               $sites = $this->siteStore->getSites();
+                               if ( $sites->hasNavigationId( $lang ) ) {
+                                       $site = $sites->getSiteByNavigationId( 
$lang );
                                        $wiki = $site->getGlobalId();
                                        $links[$wiki] = $page;
                                } else {
@@ -429,7 +430,7 @@
        private function addLinksToOutput( array $links, ParserOutput $out ) {
                foreach ( $links as $siteId => $siteLink ) {
                        $page = $siteLink->getPageName();
-                       $targetSite = $this->sites->getSite( $siteId );
+                       $targetSite = $this->siteStore->getSite( $siteId );
 
                        if ( !$targetSite ) {
                                wfLogWarning( "Unknown wiki '$siteId' used as 
sitelink target" );
diff --git a/client/includes/WikibaseClient.php 
b/client/includes/WikibaseClient.php
index 7ed0f92..63a4d01 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -538,7 +538,7 @@
                                $this->getNamespaceChecker(),
                                $this->getStore()->getSiteLinkTable(),
                                $this->getStore()->getEntityLookup(),
-                               $this->getSiteStore()->getSites(),
+                               $this->getSiteStore(),
                                $this->getLangLinkSiteGroup()
                        );
                }
diff --git a/client/tests/phpunit/includes/LangLinkHandlerTest.php 
b/client/tests/phpunit/includes/LangLinkHandlerTest.php
index e98fb3e..1c09e08 100644
--- a/client/tests/phpunit/includes/LangLinkHandlerTest.php
+++ b/client/tests/phpunit/includes/LangLinkHandlerTest.php
@@ -88,7 +88,7 @@
                        new NamespaceChecker( array( NS_TALK ), array() ),
                        $this->mockRepo,
                        $this->mockRepo,
-                       $siteStore->getSites(),
+                       $siteStore,
                        'wikipedia'
                );
        }
diff --git 
a/client/tests/phpunit/includes/hooks/ParserAfterParserHookHandlerTest.php 
b/client/tests/phpunit/includes/hooks/ParserAfterParserHookHandlerTest.php
index 8ba63b9..5e0ba9f 100644
--- a/client/tests/phpunit/includes/hooks/ParserAfterParserHookHandlerTest.php
+++ b/client/tests/phpunit/includes/hooks/ParserAfterParserHookHandlerTest.php
@@ -178,7 +178,7 @@
                        $namespaceChecker,
                        $mockRepo,
                        $mockRepo,
-                       $this->getSiteStore()->getSites(),
+                       $this->getSiteStore(),
                        $settings->getSetting( 'languageLinkSiteGroup' )
                );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/180053
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9e6de257f32dab6d49de5852f56dfba7a182994c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.25wmf12c
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to