rdbms: re-add DB domain sanity checks to LoadBalancer
[lhc/web/wiklou.git] / includes / libs / rdbms / loadbalancer / LoadBalancer.php
index d5e65cd..672c3bd 100644 (file)
@@ -28,6 +28,7 @@ use BagOStuff;
 use EmptyBagOStuff;
 use WANObjectCache;
 use ArrayUtils;
+use UnexpectedValueException;
 use InvalidArgumentException;
 use RuntimeException;
 use Exception;
@@ -998,8 +999,13 @@ class LoadBalancer implements ILoadBalancer {
                        }
                }
 
-               // Increment reference count
                if ( $conn instanceof IDatabase ) {
+                       // Final sanity check to make sure the right domain is selected
+                       if ( !$domainInstance->isCompatible( $conn->getDomainID() ) ) {
+                               throw new UnexpectedValueException(
+                                       "Got connection to '{$conn->getDomainID()}', but expected '$domain'." );
+                       }
+                       // Increment reference count
                        $refCount = $conn->getLBInfo( 'foreignPoolRefCount' );
                        $conn->setLBInfo( 'foreignPoolRefCount', $refCount + 1 );
                }