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' );
+               $tests['Special group'] = array(
+                       array( 'wikipedia', 'wikisource', 'special' ),
+                       $siteStore->getSite( 'eswiki' ),
+                       $result
+               );
+
+               $result = new SiteList();
+               $result[] = $siteStore->getSite( 'frwikisource' );
+               $result[] = $siteStore->getSite( 'wikidatawiki' );
+               $tests['Special group + language'] = array(
+                       array( 'wikipedia', 'wikisource', 'special' ),
+                       $siteStore->getSite( 'frwiki' ),
                        $result
                );
 
@@ -149,6 +166,12 @@
                $site->setLanguageCode( 'en' );
                $sites[] = $site;
 
+               $site = new MediaWikiSite();
+               $site->setGlobalId( 'wikidatawiki' );
+               $site->setGroup( 'wikidata' );
+               $site->setLanguageCode( 'en' );
+               $sites[] = $site;
+
                return new MockSiteStore( $sites );
        }
 }
\ No newline at end of file
diff --git a/client/tests/phpunit/includes/WikibaseClientTest.php 
b/client/tests/phpunit/includes/WikibaseClientTest.php
index 048edc7..79f8600 100644
--- a/client/tests/phpunit/includes/WikibaseClientTest.php
+++ b/client/tests/phpunit/includes/WikibaseClientTest.php
@@ -184,16 +184,8 @@
        }
 
        public function testGetOtherProjectsSitesProvider() {
-               $settings = $this->getDefaultInstance()->getSettings();
-
-               $siteGlobalID = $settings->getSetting( 'siteGlobalID' );
-
-               $settings->setSetting( 'siteGlobalID', 'enwiki' );
-
                $returnValue = 
$this->getDefaultInstance()->getOtherProjectsSitesProvider();
                $this->assertInstanceOf( 
'Wikibase\Client\OtherProjectsSitesProvider', $returnValue );
-
-               $settings->setSetting( 'siteGlobalID', $siteGlobalID );
        }
 
        public function testGetDefaultInstance() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I07abcbafbd18a66089685f8fba7164744f9011c9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.24-wmf14
Gerrit-Owner: Hoo man <h...@online.de>

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

Reply via email to