Aude has uploaded a new change for review.
https://gerrit.wikimedia.org/r/173242
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(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/42/173242/1
diff --git a/client/includes/OtherProjectsSitesProvider.php
b/client/includes/OtherProjectsSitesProvider.php
index 4c11a34..240d3a8 100644
--- a/client/includes/OtherProjectsSitesProvider.php
+++ b/client/includes/OtherProjectsSitesProvider.php
@@ -18,9 +18,9 @@
class OtherProjectsSitesProvider {
/**
- * @param SiteStore $siteStore
+ * @param SiteList $sites
*/
- private $siteStore;
+ private $sites;
/**
* @var Site
@@ -33,12 +33,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 +100,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: newchange
Gerrit-Change-Id: I8efd3cf1ea3d97835e43544d891d95487cb294fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits