Merge "rdbms: add ILBFactory::redefineLocalDomain method"
[lhc/web/wiklou.git] / includes / libs / rdbms / loadbalancer / LoadBalancer.php
index 7721707..8d95276 100644 (file)
@@ -1281,6 +1281,11 @@ class LoadBalancer implements ILoadBalancer {
        }
 
        public function closeConnection( IDatabase $conn ) {
+               if ( $conn instanceof DBConnRef ) {
+                       // Avoid calling close() but still leaving the handle in the pool
+                       throw new RuntimeException( __METHOD__ . ': got DBConnRef instance.' );
+               }
+
                $serverIndex = $conn->getLBInfo( 'serverIndex' );
                foreach ( $this->conns as $type => $connsByServer ) {
                        if ( !isset( $connsByServer[$serverIndex] ) ) {
@@ -1945,6 +1950,12 @@ class LoadBalancer implements ILoadBalancer {
                } );
        }
 
+       public function redefineLocalDomain( $domain ) {
+               $this->closeAll();
+
+               $this->setLocalDomain( DatabaseDomain::newFromId( $domain ) );
+       }
+
        /**
         * @param DatabaseDomain $domain
         */