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

Change subject: Avoid calling SiteStore::getSites to boost performance
......................................................................


Avoid calling SiteStore::getSites to boost performance

Change-Id: I77aab6e9fd3a301d293942c6393979df2160eaf6
(cherry picked from commit cb15f4453f34136760a0b9d7dff07dfd4463be19)
---
M client/includes/OtherProjectsSitesProvider.php
M client/includes/WikibaseClient.php
M client/includes/hooks/OtherProjectsSidebarGenerator.php
M client/includes/hooks/OtherProjectsSidebarGeneratorFactory.php
M client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php
M client/tests/phpunit/includes/hooks/OtherProjectsSidebarGeneratorTest.php
6 files changed, 22 insertions(+), 21 deletions(-)

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



diff --git a/client/includes/OtherProjectsSitesProvider.php 
b/client/includes/OtherProjectsSitesProvider.php
index 4068e2a..f4fd81d 100644
--- a/client/includes/OtherProjectsSitesProvider.php
+++ b/client/includes/OtherProjectsSitesProvider.php
@@ -4,6 +4,7 @@
 
 use Site;
 use SiteList;
+use SiteStore;
 
 /**
  * Provides a list of sites that should be displayed in the "other project" 
sidebar
@@ -17,9 +18,9 @@
 class OtherProjectsSitesProvider {
 
        /**
-        * @param SiteList $sites
+        * @param SiteStore
         */
-       private $sites;
+       private $siteStore;
 
        /**
         * @var Site
@@ -32,12 +33,12 @@
        private $specialSiteGroups;
 
        /**
-        * @param SiteList $sites
+        * @param SiteStore $siteStore
         * @param Site $currentSite
         * @param string[] $specialSiteGroups
         */
-       public function __construct( SiteList $sites, Site $currentSite, array 
$specialSiteGroups ) {
-               $this->sites = $sites;
+       public function __construct( SiteStore $siteStore, Site $currentSite, 
array $specialSiteGroups ) {
+               $this->siteStore = $siteStore;
                $this->currentSite = $currentSite;
                $this->specialSiteGroups = $specialSiteGroups;
        }
@@ -50,7 +51,7 @@
         *
         * @param string[] $supportedSiteGroupIds
         *
-        * @return SiteList
+        * @return SiteStore
         */
        public function getOtherProjectsSites( array $supportedSiteGroupIds ) {
                $currentGroupId = $this->currentSite->getGroup();
@@ -99,7 +100,7 @@
         * @return Site|null
         */
        private function getSiteForGroup( $groupId ) {
-               $siteGroupList = $this->sites->getGroup( $groupId );
+               $siteGroupList = $this->siteStore->getSites()->getGroup( 
$groupId );
                if ( $siteGroupList->count() === 1 ) {
                        return $siteGroupList[0];
                }
diff --git a/client/includes/WikibaseClient.php 
b/client/includes/WikibaseClient.php
index 7811d9c..17b3517 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -706,7 +706,7 @@
         */
        public function getOtherProjectsSitesProvider() {
                return new OtherProjectsSitesProvider(
-                       $this->getSiteStore()->getSites(),
+                       $this->getSiteStore(),
                        $this->getSite(),
                        $this->settings->getSetting( 'specialSiteLinkGroups' )
                );
diff --git a/client/includes/hooks/OtherProjectsSidebarGenerator.php 
b/client/includes/hooks/OtherProjectsSidebarGenerator.php
index b18e478..01b394e 100644
--- a/client/includes/hooks/OtherProjectsSidebarGenerator.php
+++ b/client/includes/hooks/OtherProjectsSidebarGenerator.php
@@ -3,7 +3,7 @@
 namespace Wikibase\Client\Hooks;
 
 use Site;
-use SiteList;
+use SiteStore;
 use Title;
 use Wikibase\DataModel\SiteLink;
 use Wikibase\Lib\Store\SiteLinkLookup;
@@ -29,9 +29,9 @@
        private $siteLinkLookup;
 
        /**
-        * @var SiteList
+        * @var SiteStore
         */
-       private $siteList;
+       private $siteStore;
 
        /**
         * @var string[]
@@ -41,15 +41,15 @@
        /**
         * @param string $localSiteId
         * @param SiteLinkLookup $siteLinkLookup
-        * @param SiteList $siteList
+        * @param SiteStore $siteStore
         * @param string[] $siteIdsToOutput
         */
-       public function __construct( $localSiteId, SiteLinkLookup 
$siteLinkLookup, SiteList $siteList,
+       public function __construct( $localSiteId, SiteLinkLookup 
$siteLinkLookup, SiteStore $siteStore,
                array $siteIdsToOutput
        ) {
                $this->localSiteId = $localSiteId;
                $this->siteLinkLookup = $siteLinkLookup;
-               $this->siteList = $siteList;
+               $this->siteStore = $siteStore;
                $this->siteIdsToOutput = $siteIdsToOutput;
        }
 
@@ -74,7 +74,7 @@
                        if ( !in_array( $siteLink->getSiteId(), 
$this->siteIdsToOutput ) ) {
                                continue;
                        }
-                       $site = $this->siteList->getSite( 
$siteLink->getSiteId() );
+                       $site = $this->siteStore->getSite( 
$siteLink->getSiteId() );
                        if ( $site === null ) {
                                continue;
                        }
diff --git a/client/includes/hooks/OtherProjectsSidebarGeneratorFactory.php 
b/client/includes/hooks/OtherProjectsSidebarGeneratorFactory.php
index fa2a7f9..c1ea182 100644
--- a/client/includes/hooks/OtherProjectsSidebarGeneratorFactory.php
+++ b/client/includes/hooks/OtherProjectsSidebarGeneratorFactory.php
@@ -67,7 +67,7 @@
                return new OtherProjectsSidebarGenerator(
                        $this->settings->getSetting( 'siteGlobalID' ),
                        $this->siteLinkLookup,
-                       $this->siteStore->getSites(),
+                       $this->siteStore,
                        $this->settings->getSetting( 'otherProjectsLinks' )
                );
        }
diff --git a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php 
b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php
index f682702..5cbe92c 100644
--- a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php
+++ b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php
@@ -28,9 +28,9 @@
         * @dataProvider otherProjectSitesProvider
         */
        public function testOtherProjectSites( array $supportedSites, Site 
$inputSite, SiteList $expectedSites ) {
-               $sites = $this->getSiteStoreMock()->getSites();
+               $siteStore = $this->getSiteStoreMock();
 
-               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$sites, $inputSite, array( 'wikidata' ) );
+               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$siteStore, $inputSite, array( 'wikidata' ) );
 
                $this->assertEquals(
                        $expectedSites,
@@ -42,8 +42,8 @@
         * @dataProvider otherProjectSitesProvider
         */
        public function testOtherProjectSiteIds( array $supportedSites, Site 
$inputSite, SiteList $expectedSites ) {
-               $sites = $this->getSiteStoreMock()->getSites();
-               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$sites, $inputSite, array( 'wikidata' ) );
+               $siteStore = $this->getSiteStoreMock();
+               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$siteStore, $inputSite, array( 'wikidata' ) );
 
                $expectedSiteIds = array();
                foreach ( $expectedSites as $site ) {
diff --git 
a/client/tests/phpunit/includes/hooks/OtherProjectsSidebarGeneratorTest.php 
b/client/tests/phpunit/includes/hooks/OtherProjectsSidebarGeneratorTest.php
index 8d319cf..01b7760 100644
--- a/client/tests/phpunit/includes/hooks/OtherProjectsSidebarGeneratorTest.php
+++ b/client/tests/phpunit/includes/hooks/OtherProjectsSidebarGeneratorTest.php
@@ -38,7 +38,7 @@
                $otherProjectSidebarGenerator = new 
OtherProjectsSidebarGenerator(
                        'enwiki',
                        $mockRepo,
-                       $siteStore->getSites(),
+                       $siteStore,
                        $siteIdsToOutput
                );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I77aab6e9fd3a301d293942c6393979df2160eaf6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.25wmf10
Gerrit-Owner: Hoo man <h...@online.de>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to