Jeroen De Dauw has submitted this change and it was merged.

Change subject: inject SiteList in OtherProjectsSitesProvider instead of 
calling getSites many times
......................................................................


inject SiteList in OtherProjectsSitesProvider instead of calling getSites many 
times

Change-Id: I8efd3cf1ea3d97835e43544d891d95487cb294fa
---
M client/includes/OtherProjectsSitesProvider.php
M client/includes/WikibaseClient.php
M client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php
3 files changed, 12 insertions(+), 13 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved



diff --git a/client/includes/OtherProjectsSitesProvider.php 
b/client/includes/OtherProjectsSitesProvider.php
index 4c11a34..4068e2a 100644
--- a/client/includes/OtherProjectsSitesProvider.php
+++ b/client/includes/OtherProjectsSitesProvider.php
@@ -4,7 +4,6 @@
 
 use Site;
 use SiteList;
-use SiteStore;
 
 /**
  * Provides a list of sites that should be displayed in the "other project" 
sidebar
@@ -18,9 +17,9 @@
 class OtherProjectsSitesProvider {
 
        /**
-        * @param SiteStore $siteStore
+        * @param SiteList $sites
         */
-       private $siteStore;
+       private $sites;
 
        /**
         * @var Site
@@ -33,12 +32,12 @@
        private $specialSiteGroups;
 
        /**
-        * @param SiteStore $siteStore
+        * @param SiteList $sites
         * @param Site $currentSite
         * @param string[] $specialSiteGroups
         */
-       public function __construct( SiteStore $siteStore, Site $currentSite, 
array $specialSiteGroups ) {
-               $this->siteStore = $siteStore;
+       public function __construct( SiteList $sites, Site $currentSite, array 
$specialSiteGroups ) {
+               $this->sites = $sites;
                $this->currentSite = $currentSite;
                $this->specialSiteGroups = $specialSiteGroups;
        }
@@ -100,7 +99,7 @@
         * @return Site|null
         */
        private function getSiteForGroup( $groupId ) {
-               $siteGroupList = $this->siteStore->getSites()->getGroup( 
$groupId );
+               $siteGroupList = $this->sites->getGroup( $groupId );
                if ( $siteGroupList->count() === 1 ) {
                        return $siteGroupList[0];
                }
diff --git a/client/includes/WikibaseClient.php 
b/client/includes/WikibaseClient.php
index ae30502..0e11503 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -717,7 +717,7 @@
         */
        public function getOtherProjectsSitesProvider() {
                return new OtherProjectsSitesProvider(
-                       $this->getSiteStore(),
+                       $this->getSiteStore()->getSites(),
                        $this->getSite(),
                        $this->getSettings()->getSetting( 
'specialSiteLinkGroups' )
                );
diff --git a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php 
b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php
index 79bdaef..4c32458 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 ) {
-               $siteStore = $this->getSiteStoreMock();
+               $sites = $this->getSiteStoreMock()->getSites();
 
-               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$siteStore, $inputSite, array( 'wikidata' ) );
+               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$sites, $inputSite, array( 'wikidata' ) );
 
                $this->assertEquals(
                        $expectedSites,
@@ -42,8 +42,8 @@
         * @dataProvider otherProjectSitesProvider
         */
        public function testOtherProjectSiteIds( array $supportedSites, Site 
$inputSite, SiteList $expectedSites ) {
-               $siteStore = $this->getSiteStoreMock();
-               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$siteStore, $inputSite, array( 'wikidata' ) );
+               $sites = $this->getSiteStoreMock()->getSites();
+               $otherProjectsSitesProvider = new OtherProjectsSitesProvider( 
$sites, $inputSite, array( 'wikidata' ) );
 
                $expectedSiteIds = array();
                foreach ( $expectedSites as $site ) {
@@ -172,4 +172,4 @@
 
                return new MockSiteStore( $sites );
        }
-}
\ No newline at end of file
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8efd3cf1ea3d97835e43544d891d95487cb294fa
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.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