Bene has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/116746

Change subject: DNM Use SiteList::getSiteByNavigationId in LangLinkHandler
......................................................................

DNM Use SiteList::getSiteByNavigationId in LangLinkHandler

This patch uses the new feature introduced in 
https://gerrit.wikimedia.org/r/#/c/116730/
Do not merge this patch until the other one got merged.

Change-Id: Ic09c2593f7c0844a1ecd34d5283772e195e2b5cd
---
M client/includes/LangLinkHandler.php
1 file changed, 8 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/46/116746/1

diff --git a/client/includes/LangLinkHandler.php 
b/client/includes/LangLinkHandler.php
index 2343f4b..cce1742 100644
--- a/client/includes/LangLinkHandler.php
+++ b/client/includes/LangLinkHandler.php
@@ -172,14 +172,13 @@
                                return array();
                        }
 
-                       $site = $this->getSiteByNavigationId( $code );
+                       $siteList = $this->sites->getSites();
 
-                       if ( $site === false ) {
-                               continue;
+                       if ( $siteList->hasNavigationId( $code ) ) {
+                               $site = $siteList->getSiteByNavigationId( $code 
);
+                               $wiki = $site->getGlobalId();
+                               unset( $repoLinks[$wiki] );
                        }
-
-                       $wiki = $site->getGlobalId();
-                       unset( $repoLinks[$wiki] );
                }
 
                unset( $repoLinks[$this->siteId] ); // remove self-link
@@ -272,38 +271,6 @@
        }
 
        /**
-        * Returns a Site object for the given navigational ID (alias 
inter-language prefix).
-        *
-        * @since 0.4
-        *
-        * @todo: move this functionality into Sites/SiteList/SiteArray!
-        *
-        * @param string $id The navigation ID to find a site for.
-        *
-        * @return bool|Site The site with the given navigational ID, or false 
if not found.
-        */
-       protected function getSiteByNavigationId( $id ) {
-               wfProfileIn( __METHOD__ );
-
-               //FIXME: this needs to be moved into core, into SiteList resp. 
SiteArray!
-               if ( $this->sitesByNavigationId === null ) {
-                       $this->sitesByNavigationId = array();
-
-                       /* @var Site $site */
-                       foreach ( $this->sites->getSites() as $site ) {
-                               $ids = $site->getNavigationIds();
-
-                               foreach ( $ids as $navId ) {
-                                       $this->sitesByNavigationId[$navId] = 
$site;
-                               }
-                       }
-               }
-
-               wfProfileOut( __METHOD__ );
-               return isset( $this->sitesByNavigationId[$id] ) ? 
$this->sitesByNavigationId[$id] : false;
-       }
-
-       /**
         * Converts a list of interwiki links into an associative array that 
maps
         * global site IDs to the respective target pages on the designated 
wikis.
         *
@@ -326,9 +293,10 @@
                                $lang = $parts[0];
                                $page = $parts[1];
 
-                               $site = $this->getSiteByNavigationId( $lang );
+                               $siteList = $this->sites->getSites();
 
-                               if ( $site ) {
+                               if ( $siteList->hasNavigationId( $lang ) ) {
+                                       $site = 
$siteList->getSiteByNavigationId( $lang );
                                        $wiki = $site->getGlobalId();
                                        $links[$wiki] = $page;
                                } else {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic09c2593f7c0844a1ecd34d5283772e195e2b5cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <benestar.wikime...@googlemail.com>

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

Reply via email to