[MediaWiki-commits] [Gerrit] Make otherProjectsLinks setting compatible with the speci... - change (mediawiki...Wikibase)
Hoo man has uploaded a new change for review. https://gerrit.wikimedia.org/r/150211 Change subject: Make otherProjectsLinks setting compatible with the special sitelink group .. Make otherProjectsLinks setting compatible with the special sitelink group Deploy: Requires the specialSiteLinkGroups setting to be set on client. Change-Id: I07abcbafbd18a66089685f8fba7164744f9011c9 (cherry picked from commit 6acd5c4866b06fa5da0603d95ed94367e8b7f757) --- M client/includes/OtherProjectsSitesProvider.php M client/includes/WikibaseClient.php M client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php M client/tests/phpunit/includes/WikibaseClientTest.php 4 files changed, 50 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/11/150211/1 diff --git a/client/includes/OtherProjectsSitesProvider.php b/client/includes/OtherProjectsSitesProvider.php index 802e58f..f3016fe 100644 --- a/client/includes/OtherProjectsSitesProvider.php +++ b/client/includes/OtherProjectsSitesProvider.php @@ -28,12 +28,18 @@ private $currentSite; /** +* @var array +*/ + private $specialSiteGroups; + + /** * @param SiteStore $siteStore * @param Site $currentSite */ - public function __construct( SiteStore $siteStore, Site $currentSite ) { + public function __construct( SiteStore $siteStore, Site $currentSite, array $specialSiteGroups ) { $this-siteStore = $siteStore; $this-currentSite = $currentSite; + $this-specialSiteGroups = $specialSiteGroups; } /** @@ -50,6 +56,7 @@ $currentGroupId = $this-currentSite-getGroup(); $otherProjectsSites = new SiteList(); + $this-expandSpecialGroups( $supportedSiteGroupIds ); foreach ( $supportedSiteGroupIds as $groupId ) { if ( $groupId === $currentGroupId ) { continue; @@ -106,4 +113,16 @@ return null; } + + /** +* @param array $groups +*/ + private function expandSpecialGroups( $groups ) { + if ( !in_array( 'special', $groups ) ) { + return; + } + + $groups = array_diff( $groups, array( 'special' ) ); + $groups = array_merge( $groups, $this-specialSiteGroups ); + } } \ No newline at end of file diff --git a/client/includes/WikibaseClient.php b/client/includes/WikibaseClient.php index e05b748..7243de8 100644 --- a/client/includes/WikibaseClient.php +++ b/client/includes/WikibaseClient.php @@ -683,6 +683,10 @@ * @return OtherProjectsSitesProvider */ public function getOtherProjectsSitesProvider() { - return new OtherProjectsSitesProvider( $this-getSiteStore(), $this-getSite() ); + return new OtherProjectsSitesProvider( + $this-getSiteStore(), + $this-getSite(), + $this-getSettings()-getSetting( 'specialSiteLinkGroups' ) + ); } } diff --git a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php index 2d91001..292cc03 100644 --- a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php +++ b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php @@ -32,7 +32,7 @@ public function testOtherProjectSites( array $supportedSites, Site $inputSite, SiteList $expectedSites ) { $siteStore = $this-getSiteStoreMock(); - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array( 'wikidata' ) ); $this-assertEquals( $expectedSites, @@ -45,7 +45,7 @@ */ public function testOtherProjectSiteIds( array $supportedSites, Site $inputSite, SiteList $expectedSites ) { $siteStore = $this-getSiteStoreMock(); - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array( 'wikidata' ) ); $expectedSiteIds = array(); foreach ( $expectedSites as $site ) { @@ -84,6 +84,23 @@ $tests['Only one in group'] = array( array( 'wikipedia', 'wikisource', 'commons' ), $siteStore-getSite( 'eswiki' ), + $result + ); + + $result = new SiteList(); + $result[] = $siteStore-getSite( 'wikidatawiki' ); +
[MediaWiki-commits] [Gerrit] Make otherProjectsLinks setting compatible with the speci... - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Make otherProjectsLinks setting compatible with the special sitelink group .. Make otherProjectsLinks setting compatible with the special sitelink group Deploy: Requires the specialSiteLinkGroups setting to be set on client. Change-Id: I07abcbafbd18a66089685f8fba7164744f9011c9 (cherry picked from commit 6acd5c4866b06fa5da0603d95ed94367e8b7f757) --- M client/includes/OtherProjectsSitesProvider.php M client/includes/WikibaseClient.php M client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php M client/tests/phpunit/includes/WikibaseClientTest.php 4 files changed, 50 insertions(+), 12 deletions(-) Approvals: Hoo man: Looks good to me, approved WikidataJenkins: Verified jenkins-bot: Verified diff --git a/client/includes/OtherProjectsSitesProvider.php b/client/includes/OtherProjectsSitesProvider.php index 802e58f..f3016fe 100644 --- a/client/includes/OtherProjectsSitesProvider.php +++ b/client/includes/OtherProjectsSitesProvider.php @@ -28,12 +28,18 @@ private $currentSite; /** +* @var array +*/ + private $specialSiteGroups; + + /** * @param SiteStore $siteStore * @param Site $currentSite */ - public function __construct( SiteStore $siteStore, Site $currentSite ) { + public function __construct( SiteStore $siteStore, Site $currentSite, array $specialSiteGroups ) { $this-siteStore = $siteStore; $this-currentSite = $currentSite; + $this-specialSiteGroups = $specialSiteGroups; } /** @@ -50,6 +56,7 @@ $currentGroupId = $this-currentSite-getGroup(); $otherProjectsSites = new SiteList(); + $this-expandSpecialGroups( $supportedSiteGroupIds ); foreach ( $supportedSiteGroupIds as $groupId ) { if ( $groupId === $currentGroupId ) { continue; @@ -106,4 +113,16 @@ return null; } + + /** +* @param array $groups +*/ + private function expandSpecialGroups( $groups ) { + if ( !in_array( 'special', $groups ) ) { + return; + } + + $groups = array_diff( $groups, array( 'special' ) ); + $groups = array_merge( $groups, $this-specialSiteGroups ); + } } \ No newline at end of file diff --git a/client/includes/WikibaseClient.php b/client/includes/WikibaseClient.php index e05b748..7243de8 100644 --- a/client/includes/WikibaseClient.php +++ b/client/includes/WikibaseClient.php @@ -683,6 +683,10 @@ * @return OtherProjectsSitesProvider */ public function getOtherProjectsSitesProvider() { - return new OtherProjectsSitesProvider( $this-getSiteStore(), $this-getSite() ); + return new OtherProjectsSitesProvider( + $this-getSiteStore(), + $this-getSite(), + $this-getSettings()-getSetting( 'specialSiteLinkGroups' ) + ); } } diff --git a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php index 2d91001..292cc03 100644 --- a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php +++ b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php @@ -32,7 +32,7 @@ public function testOtherProjectSites( array $supportedSites, Site $inputSite, SiteList $expectedSites ) { $siteStore = $this-getSiteStoreMock(); - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array( 'wikidata' ) ); $this-assertEquals( $expectedSites, @@ -45,7 +45,7 @@ */ public function testOtherProjectSiteIds( array $supportedSites, Site $inputSite, SiteList $expectedSites ) { $siteStore = $this-getSiteStoreMock(); - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array( 'wikidata' ) ); $expectedSiteIds = array(); foreach ( $expectedSites as $site ) { @@ -84,6 +84,23 @@ $tests['Only one in group'] = array( array( 'wikipedia', 'wikisource', 'commons' ), $siteStore-getSite( 'eswiki' ), + $result + ); + + $result = new SiteList(); + $result[] = $siteStore-getSite( 'wikidatawiki' ); + $tests['Special
[MediaWiki-commits] [Gerrit] Make otherProjectsLinks setting compatible with the speci... - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Make otherProjectsLinks setting compatible with the special sitelink group .. Make otherProjectsLinks setting compatible with the special sitelink group Deploy: Requires the specialSiteLinkGroups setting to be set on client. Change-Id: I07abcbafbd18a66089685f8fba7164744f9011c9 --- M client/includes/OtherProjectsSitesProvider.php M client/includes/WikibaseClient.php M client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php M client/tests/phpunit/includes/WikibaseClientTest.php 4 files changed, 50 insertions(+), 12 deletions(-) Approvals: Aude: Looks good to me, approved WikidataJenkins: Verified jenkins-bot: Verified diff --git a/client/includes/OtherProjectsSitesProvider.php b/client/includes/OtherProjectsSitesProvider.php index 802e58f..f3016fe 100644 --- a/client/includes/OtherProjectsSitesProvider.php +++ b/client/includes/OtherProjectsSitesProvider.php @@ -28,12 +28,18 @@ private $currentSite; /** +* @var array +*/ + private $specialSiteGroups; + + /** * @param SiteStore $siteStore * @param Site $currentSite */ - public function __construct( SiteStore $siteStore, Site $currentSite ) { + public function __construct( SiteStore $siteStore, Site $currentSite, array $specialSiteGroups ) { $this-siteStore = $siteStore; $this-currentSite = $currentSite; + $this-specialSiteGroups = $specialSiteGroups; } /** @@ -50,6 +56,7 @@ $currentGroupId = $this-currentSite-getGroup(); $otherProjectsSites = new SiteList(); + $this-expandSpecialGroups( $supportedSiteGroupIds ); foreach ( $supportedSiteGroupIds as $groupId ) { if ( $groupId === $currentGroupId ) { continue; @@ -106,4 +113,16 @@ return null; } + + /** +* @param array $groups +*/ + private function expandSpecialGroups( $groups ) { + if ( !in_array( 'special', $groups ) ) { + return; + } + + $groups = array_diff( $groups, array( 'special' ) ); + $groups = array_merge( $groups, $this-specialSiteGroups ); + } } \ No newline at end of file diff --git a/client/includes/WikibaseClient.php b/client/includes/WikibaseClient.php index 5e48a5d..e39f341 100644 --- a/client/includes/WikibaseClient.php +++ b/client/includes/WikibaseClient.php @@ -713,6 +713,10 @@ * @return OtherProjectsSitesProvider */ public function getOtherProjectsSitesProvider() { - return new OtherProjectsSitesProvider( $this-getSiteStore(), $this-getSite() ); + return new OtherProjectsSitesProvider( + $this-getSiteStore(), + $this-getSite(), + $this-getSettings()-getSetting( 'specialSiteLinkGroups' ) + ); } } diff --git a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php index 2d91001..292cc03 100644 --- a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php +++ b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php @@ -32,7 +32,7 @@ public function testOtherProjectSites( array $supportedSites, Site $inputSite, SiteList $expectedSites ) { $siteStore = $this-getSiteStoreMock(); - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array( 'wikidata' ) ); $this-assertEquals( $expectedSites, @@ -45,7 +45,7 @@ */ public function testOtherProjectSiteIds( array $supportedSites, Site $inputSite, SiteList $expectedSites ) { $siteStore = $this-getSiteStoreMock(); - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array( 'wikidata' ) ); $expectedSiteIds = array(); foreach ( $expectedSites as $site ) { @@ -84,6 +84,23 @@ $tests['Only one in group'] = array( array( 'wikipedia', 'wikisource', 'commons' ), $siteStore-getSite( 'eswiki' ), + $result + ); + + $result = new SiteList(); + $result[] = $siteStore-getSite( 'wikidatawiki' ); + $tests['Special group'] = array( + array( 'wikipedia', 'wikisource',
[MediaWiki-commits] [Gerrit] Make otherProjectsLinks setting compatible with the speci... - change (mediawiki...Wikibase)
Hoo man has uploaded a new change for review. https://gerrit.wikimedia.org/r/148993 Change subject: Make otherProjectsLinks setting compatible with the special sitelink group .. Make otherProjectsLinks setting compatible with the special sitelink group Change-Id: I07abcbafbd18a66089685f8fba7164744f9011c9 --- M client/includes/OtherProjectsSitesProvider.php M client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php 2 files changed, 36 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/93/148993/1 diff --git a/client/includes/OtherProjectsSitesProvider.php b/client/includes/OtherProjectsSitesProvider.php index e8c93b0..72a0d28 100644 --- a/client/includes/OtherProjectsSitesProvider.php +++ b/client/includes/OtherProjectsSitesProvider.php @@ -28,12 +28,18 @@ private $currentSite; /** +* @var array +*/ + private $specialSiteGroups; + + /** * @param SiteStore $siteStore * @param Site $currentSite */ - public function __construct( SiteStore $siteStore, Site $currentSite ) { + public function __construct( SiteStore $siteStore, Site $currentSite, array $specialSiteGroups ) { $this-siteStore = $siteStore; $this-currentSite = $currentSite; + $this-specialSiteGroups = $specialSiteGroups; } /** @@ -50,8 +56,9 @@ if ( !$localSite ) { return array(); } + $specialSiteGroups = $settings-getSetting( 'specialSiteLinkGroups' ); - $otherProjectsSitesProvider = new self( $sitesStore, $localSite ); + $otherProjectsSitesProvider = new self( $sitesStore, $localSite, $specialSiteGroups ); $otherProjectsSites = $otherProjectsSitesProvider-getOtherProjectsSites( $settings-getSetting( 'siteLinkGroups' ) ); $otherProjectsSiteIds = array(); @@ -75,6 +82,8 @@ public function getOtherProjectsSites( array $supportedSiteGroupIds ) { $currentGroupId = $this-currentSite-getGroup(); $otherProjectsSites = new SiteList(); + + $this-substituteSpecialSiteGroups( $supportedSiteGroupIds ); foreach ( $supportedSiteGroupIds as $groupId ) { if ( $groupId === $currentGroupId ) { @@ -115,4 +124,16 @@ return null; } + + /** +* @param array $groups +*/ + private function substituteSpecialSiteGroups( $groups ) { + if ( !in_array( 'special', $groups ) ) { + return; + } + + $groups = array_diff( $groups, array( 'special' ) ); + $groups = array_merge( $groups, $this-specialSiteGroups ); + } } \ No newline at end of file diff --git a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php index f4074c3..07d02dd 100644 --- a/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php +++ b/client/tests/phpunit/includes/OtherProjectsSitesProviderTest.php @@ -6,7 +6,6 @@ use Site; use SiteList; use SiteStore; -use TestSites; use Wikibase\Client\OtherProjectsSitesProvider; use Wikibase\Client\WikibaseClient; use Wikibase\Test\MockSiteStore; @@ -31,7 +30,7 @@ * @dataProvider otherProjectSitesProvider */ public function testOtherProjectSites( SiteStore $siteStore, array $supportedSites, Site $inputSite, SiteList $expectedSites ) { - $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite ); + $otherProjectsSitesProvider = new OtherProjectsSitesProvider( $siteStore, $inputSite, array() ); $this-assertEquals( $expectedSites, @@ -118,6 +117,12 @@ $site-setLanguageCode( 'en' ); $sites[] = $site; + $site = new MediaWikiSite(); + $site-setGlobalId( 'wikidatawiki' ); + $site-setGroup( 'wikidata' ); + $site-setLanguageCode( 'en' ); + $sites[] = $site; + return $sites; } @@ -137,11 +142,13 @@ $siteStore-saveSites( $sites ); + $oldSpecialSiteLinkGroups = $settings-getSetting( 'specialSiteLinkGroups' ); $oldSiteGlobalId = $settings-getSetting( 'siteGlobalID' ); $oldSiteLinkGroups = $settings-getSetting( 'siteLinkGroups' ); $settings-setSetting( 'siteGlobalID', $siteGlobalID ); $settings-setSetting( 'siteLinkGroups', $siteLinkGroups ); + $settings-setSetting( 'specialSiteLinkGroups', array( 'wikidata' ) ); $siteIds =