Avoid pointless use of isset() in LBFactoryMulti()
[lhc/web/wiklou.git] / includes / libs / rdbms / lbfactory / LBFactoryMulti.php
index 83ca650..4158e61 100644 (file)
@@ -255,18 +255,12 @@ class LBFactoryMulti extends LBFactory {
                return $this->mainLBs[$section];
        }
 
-       /**
-        * @param string $cluster
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for the current domain
-        * @throws InvalidArgumentException
-        * @return LoadBalancer
-        */
-       public function newExternalLB( $cluster, $domain = false ) {
+       public function newExternalLB( $cluster ) {
                if ( !isset( $this->externalLoads[$cluster] ) ) {
                        throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
                }
                $template = $this->serverTemplate;
-               if ( isset( $this->externalTemplateOverrides ) ) {
+               if ( $this->externalTemplateOverrides ) {
                        $template = $this->externalTemplateOverrides + $template;
                }
                if ( isset( $this->templateOverridesByCluster[$cluster] ) ) {
@@ -281,20 +275,35 @@ class LBFactoryMulti extends LBFactory {
                );
        }
 
-       /**
-        * @param string $cluster External storage cluster, or false for core
-        * @param DatabaseDomain|string|bool $domain Domain ID, or false for the current domain
-        * @return LoadBalancer
-        */
-       public function getExternalLB( $cluster, $domain = false ) {
+       public function getExternalLB( $cluster ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
-                       $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $domain );
+                       $this->extLBs[$cluster] = $this->newExternalLB( $cluster );
                        $this->getChronologyProtector()->initLB( $this->extLBs[$cluster] );
                }
 
                return $this->extLBs[$cluster];
        }
 
+       public function getAllMainLBs() {
+               $lbs = [];
+               foreach ( $this->sectionsByDB as $db => $section ) {
+                       if ( !isset( $lbs[$section] ) ) {
+                               $lbs[$section] = $this->getMainLB( $db );
+                       }
+               }
+
+               return $lbs;
+       }
+
+       public function getAllExternalLBs() {
+               $lbs = [];
+               foreach ( $this->externalLoads as $cluster => $unused ) {
+                       $lbs[$cluster] = $this->getExternalLB( $cluster );
+               }
+
+               return $lbs;
+       }
+
        /**
         * Make a new load balancer object based on template and load array
         *
@@ -339,7 +348,7 @@ class LBFactoryMulti extends LBFactory {
                        $serverInfo = $template;
                        if ( $master ) {
                                $serverInfo['master'] = true;
-                               if ( isset( $this->masterTemplateOverrides ) ) {
+                               if ( $this->masterTemplateOverrides ) {
                                        $serverInfo = $this->masterTemplateOverrides + $serverInfo;
                                }
                                $master = false;