Catrope has uploaded a new change for review.

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

Change subject: Revert "Move LBFactoryMulti to /libs/rdbms"
......................................................................

Revert "Move LBFactoryMulti to /libs/rdbms"

In order to revert I918422ae

This reverts commit 57ba462e4bc38bb6a75bdb7eef5cb7d27df59729.

Change-Id: Icd3b17c9b8713036d8eed8e3839ba2bc48e2b00f
---
M autoload.php
R includes/db/loadbalancer/LBFactoryMulti.php
M includes/libs/rdbms/lbfactory/LBFactory.php
3 files changed, 42 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/08/311608/1

diff --git a/autoload.php b/autoload.php
index 4a72799..52c929a 100644
--- a/autoload.php
+++ b/autoload.php
@@ -659,7 +659,7 @@
        'KuConverter' => __DIR__ . '/languages/classes/LanguageKu.php',
        'LBFactory' => __DIR__ . '/includes/libs/rdbms/lbfactory/LBFactory.php',
        'LBFactoryMW' => __DIR__ . '/includes/db/loadbalancer/LBFactoryMW.php',
-       'LBFactoryMulti' => __DIR__ . 
'/includes/libs/rdbms/lbfactory/LBFactoryMulti.php',
+       'LBFactoryMulti' => __DIR__ . 
'/includes/db/loadbalancer/LBFactoryMulti.php',
        'LBFactorySimple' => __DIR__ . 
'/includes/libs/rdbms/lbfactory/LBFactorySimple.php',
        'LBFactorySingle' => __DIR__ . 
'/includes/db/loadbalancer/LBFactorySingle.php',
        'LCStore' => __DIR__ . '/includes/cache/localisation/LCStore.php',
diff --git a/includes/libs/rdbms/lbfactory/LBFactoryMulti.php 
b/includes/db/loadbalancer/LBFactoryMulti.php
similarity index 86%
rename from includes/libs/rdbms/lbfactory/LBFactoryMulti.php
rename to includes/db/loadbalancer/LBFactoryMulti.php
index 0f1493a..1f7f528 100644
--- a/includes/libs/rdbms/lbfactory/LBFactoryMulti.php
+++ b/includes/db/loadbalancer/LBFactoryMulti.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Advanced generator of database load balancing objects for database farms.
+ * Advanced generator of database load balancing objects for wiki farms.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
  */
 
 /**
- * A multi-database, multi-master factory for Wikimedia and similar 
installations.
+ * A multi-wiki, multi-master factory for Wikimedia and similar installations.
  * Ignores the old configuration globals.
  *
  * Template override precedence (highest => lowest):
@@ -83,7 +83,7 @@
  *
  * @ingroup Database
  */
-class LBFactoryMulti extends LBFactory {
+class LBFactoryMulti extends LBFactoryMW {
        /** @var array A map of database names to section names */
        private $sectionsByDB;
 
@@ -94,8 +94,9 @@
        private $sectionLoads;
 
        /**
-        * @var array[] Server info associative array
-        * @note The host, hostName and load entries will be overridden
+        * @var array A server info associative array as documented for
+        * $wgDBservers. The host, hostName and load entries will be
+        * overridden
         */
        private $serverTemplate;
 
@@ -156,7 +157,7 @@
        private $loadMonitorClass;
 
        /** @var string */
-       private $lastDomain;
+       private $lastWiki;
 
        /** @var string */
        private $lastSection;
@@ -177,7 +178,7 @@
 
                foreach ( $required as $key ) {
                        if ( !isset( $conf[$key] ) ) {
-                               throw new InvalidArgumentException( __CLASS__ . 
": $key is required." );
+                               throw new InvalidArgumentException( __CLASS__ . 
": $key is required in configuration" );
                        }
                        $this->$key = $conf[$key];
                }
@@ -190,32 +191,32 @@
        }
 
        /**
-        * @param bool|string $domain
+        * @param bool|string $wiki
         * @return string
         */
-       private function getSectionForDomain( $domain = false ) {
-               if ( $this->lastDomain === $domain ) {
+       private function getSectionForWiki( $wiki = false ) {
+               if ( $this->lastWiki === $wiki ) {
                        return $this->lastSection;
                }
-               list( $dbName, ) = $this->getDBNameAndPrefix( $domain );
+               list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
                if ( isset( $this->sectionsByDB[$dbName] ) ) {
                        $section = $this->sectionsByDB[$dbName];
                } else {
                        $section = 'DEFAULT';
                }
                $this->lastSection = $section;
-               $this->lastDomain = $domain;
+               $this->lastWiki = $wiki;
 
                return $section;
        }
 
        /**
-        * @param bool|string $domain
+        * @param bool|string $wiki
         * @return LoadBalancer
         */
-       public function newMainLB( $domain = false ) {
-               list( $dbName, ) = $this->getDBNameAndPrefix( $domain );
-               $section = $this->getSectionForDomain( $domain );
+       public function newMainLB( $wiki = false ) {
+               list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
+               $section = $this->getSectionForWiki( $wiki );
                if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
                        $groupLoads = $this->groupLoadsByDB[$dbName];
                } else {
@@ -223,8 +224,7 @@
                }
 
                if ( isset( $this->groupLoadsBySection[$section] ) ) {
-                       $groupLoads = array_merge_recursive(
-                               $groupLoads, 
$this->groupLoadsBySection[$section] );
+                       $groupLoads = array_merge_recursive( $groupLoads, 
$this->groupLoadsBySection[$section] );
                }
 
                $readOnlyReason = $this->readOnlyReason;
@@ -247,13 +247,13 @@
        }
 
        /**
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for 
the current domain
+        * @param bool|string $wiki
         * @return LoadBalancer
         */
-       public function getMainLB( $domain = false ) {
-               $section = $this->getSectionForDomain( $domain );
+       public function getMainLB( $wiki = false ) {
+               $section = $this->getSectionForWiki( $wiki );
                if ( !isset( $this->mainLBs[$section] ) ) {
-                       $lb = $this->newMainLB( $domain );
+                       $lb = $this->newMainLB( $wiki );
                        $this->getChronologyProtector()->initLB( $lb );
                        $this->mainLBs[$section] = $lb;
                }
@@ -263,11 +263,11 @@
 
        /**
         * @param string $cluster
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for 
the current domain
+        * @param bool|string $wiki
         * @throws InvalidArgumentException
         * @return LoadBalancer
         */
-       protected function newExternalLB( $cluster, $domain = false ) {
+       protected function newExternalLB( $cluster, $wiki = false ) {
                if ( !isset( $this->externalLoads[$cluster] ) ) {
                        throw new InvalidArgumentException( __METHOD__ . ": 
Unknown cluster \"$cluster\"" );
                }
@@ -289,12 +289,12 @@
 
        /**
         * @param string $cluster External storage cluster, or false for core
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for 
the current domain
+        * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancer
         */
-       public function getExternalLB( $cluster, $domain = false ) {
+       public function getExternalLB( $cluster, $wiki = false ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
-                       $this->extLBs[$cluster] = $this->newExternalLB( 
$cluster, $domain );
+                       $this->extLBs[$cluster] = $this->newExternalLB( 
$cluster, $wiki );
                        $this->getChronologyProtector()->initLB( 
$this->extLBs[$cluster] );
                }
 
@@ -390,15 +390,18 @@
        }
 
        /**
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for 
the current domain
-        * @return array [database name, table prefix]
+        * Get the database name and prefix based on the wiki ID
+        * @param bool|string $wiki
+        * @return array
         */
-       private function getDBNameAndPrefix( $domain = false ) {
-               $domain = ( $domain === false )
-                       ? $this->localDomain
-                       : DatabaseDomain::newFromId( $domain );
+       private function getDBNameAndPrefix( $wiki = false ) {
+               if ( $wiki === false ) {
+                       global $wgDBname, $wgDBprefix;
 
-               return [ $domain->getDatabase(), $domain->getTablePrefix() ];
+                       return [ $wgDBname, $wgDBprefix ];
+               } else {
+                       return wfSplitWikiID( $wiki );
+               }
        }
 
        /**
diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php 
b/includes/libs/rdbms/lbfactory/LBFactory.php
index 40ba458..00474fe 100644
--- a/includes/libs/rdbms/lbfactory/LBFactory.php
+++ b/includes/libs/rdbms/lbfactory/LBFactory.php
@@ -141,7 +141,7 @@
         * Create a new load balancer object. The resulting object will be 
untracked,
         * not chronology-protected, and the caller is responsible for cleaning 
it up.
         *
-        * @param bool|string $domain Domain ID, or false for the current domain
+        * @param bool|string $domain Wiki ID, or false for the current wiki
         * @return ILoadBalancer
         */
        abstract public function newMainLB( $domain = false );
@@ -149,7 +149,7 @@
        /**
         * Get a cached (tracked) load balancer object.
         *
-        * @param bool|string $domain Domain ID, or false for the current domain
+        * @param bool|string $domain Wiki ID, or false for the current wiki
         * @return ILoadBalancer
         */
        abstract public function getMainLB( $domain = false );
@@ -160,7 +160,7 @@
         * cleaning it up.
         *
         * @param string $cluster External storage cluster, or false for core
-        * @param bool|string $domain Domain ID, or false for the current domain
+        * @param bool|string $domain Wiki ID, or false for the current wiki
         * @return ILoadBalancer
         */
        abstract protected function newExternalLB( $cluster, $domain = false );
@@ -169,7 +169,7 @@
         * Get a cached (tracked) load balancer for external storage
         *
         * @param string $cluster External storage cluster, or false for core
-        * @param bool|string $domain Domain ID, or false for the current domain
+        * @param bool|string $domain Wiki ID, or false for the current wiki
         * @return ILoadBalancer
         */
        abstract public function getExternalLB( $cluster, $domain = false );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd3b17c9b8713036d8eed8e3839ba2bc48e2b00f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>

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

Reply via email to