Aude has uploaded a new change for review.

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

Change subject: Fix loading of canonical url and site name settings
......................................................................

Fix loading of canonical url and site name settings

In the case of Wikipedia, $major needs to be 'wikipedia'
and not 'wiki'.

This worked previously because although no match was found
for the wikipedia sites, the default setting assumed
Wikipedia. The default has been removed / changed in wmf
settings so now these were null and blank.

Bug: T107064
Change-Id: I8fc92e432714a3301c6aa6615f461a3a2b380f37
---
M SiteMatrix_body.php
1 file changed, 30 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SiteMatrix 
refs/changes/50/227350/1

diff --git a/SiteMatrix_body.php b/SiteMatrix_body.php
index e794812..7d4bdc4 100644
--- a/SiteMatrix_body.php
+++ b/SiteMatrix_body.php
@@ -173,11 +173,10 @@
         * @return Mixed
         */
        public function getUrl( $minor, $major, $canonical = false ) {
-               global $wgConf;
-               $dbname = $this->getDBName( $minor, $major );
-               $minor = str_replace( '_', '-', $minor );
-               return $wgConf->get( $canonical ? 'wgCanonicalServer' : 
'wgServer',
-                       $dbname, $major, array( 'lang' => $minor, 'site' => 
$major )
+               return $this->getSetting(
+                       $canonical ? 'wgCanonicalServer' : 'wgServer',
+                       $minor,
+                       $major
                );
        }
 
@@ -187,7 +186,7 @@
         * @return Mixed
         */
        public function getCanonicalUrl( $minor, $major ) {
-               return $this->getUrl( $minor, $major, true );
+               return $this->getSetting( 'wgCanonicalServer', $minor, $major );
        }
 
        /**
@@ -196,9 +195,30 @@
         * @return string
         */
        public function getSitename( $minor, $major ) {
+               return $this->getSetting( 'wgSitename', $minor, $major );
+       }
+
+       /**
+        * @param string $setting setting name
+        * @param string $lang language subdomain
+        * @param string $dbSuffix e.g. 'wiki' for 'enwiki' or 'wikisource' for 
'enwikisource'
+        *
+        * @return mixed
+        */
+       private function getSetting( $setting, $lang, $dbSuffix ) {
                global $wgConf;
-               $dbname = $this->getDBName( $minor, $major );
-               return $wgConf->get( 'wgSitename', $dbname );
+
+               $dbname = $this->getDBName( $lang, $dbSuffix );
+
+               list( $major, $minor ) = $wgConf->siteFromDB( $dbname );
+               $minor = str_replace( '_', '-', $minor );
+
+               return $wgConf->get(
+                       $setting,
+                       $dbname,
+                       $major,
+                       array( 'lang' => $minor, 'site' => $major )
+               );
        }
 
        /**
@@ -234,6 +254,8 @@
                        // not very reliable.
                        global $wgConf;
 
+                       list( $major, $minor ) = $wgConf->siteFromDB( $dbname );
+
                        if ( $wgConf->get( 'wgReadOnly', $dbname, $major, 
array( 'site' => $major, 'lang' => $minor ) ) ) {
                                return true;
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8fc92e432714a3301c6aa6615f461a3a2b380f37
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SiteMatrix
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>
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