From: Aaron Schulz Date: Thu, 12 Apr 2018 20:15:34 +0000 (-0700) Subject: rdbms: make $i in LoadBalancer::getConnection override $groups X-Git-Tag: 1.31.0-rc.0~84^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=daf0514345f03189187606ba2323794588c79dc9 rdbms: make $i in LoadBalancer::getConnection override $groups Previously, passing a specific server index (even the master index) would result in a connection to some server in $groups or the generic read group being selected. Change-Id: Ifb497f5f4bb61f16b310d4d30fb8315e3bcdce8e --- diff --git a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php index 715f4e4d29..ce042f0327 100644 --- a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php @@ -181,7 +181,7 @@ interface ILoadBalancer { * call ILoadBalancer::reuseConnection() on the handle when finished using it. * In all other cases, this is not necessary, though not harmful either. * - * @param int $i Server index or DB_MASTER/DB_REPLICA + * @param int $i Server index (overrides $groups) or DB_MASTER/DB_REPLICA * @param array|string|bool $groups Query group(s), or false for the generic reader * @param string|bool $domain Domain ID, or false for the current domain * @param int $flags Bitfield of CONN_* class constants diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 94acc1ef05..0ed3f802ba 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -714,7 +714,7 @@ class LoadBalancer implements ILoadBalancer { if ( $i == self::DB_MASTER ) { $i = $this->getWriterIndex(); - } else { + } elseif ( $i == self::DB_REPLICA ) { # Try to find an available server in any the query groups (in order) foreach ( $groups as $group ) { $groupIndex = $this->getReaderIndex( $group, $domain );