Merge "Move variable definitions near to where they are used"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 16 Mar 2014 17:54:39 +0000 (17:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 16 Mar 2014 17:54:39 +0000 (17:54 +0000)
includes/db/LoadBalancer.php

index 5f880d6..de4c2f5 100644 (file)
@@ -493,13 +493,6 @@ class LoadBalancer {
        public function reuseConnection( $conn ) {
                $serverIndex = $conn->getLBInfo( 'serverIndex' );
                $refCount = $conn->getLBInfo( 'foreignPoolRefCount' );
-               $dbName = $conn->getDBname();
-               $prefix = $conn->tablePrefix();
-               if ( strval( $prefix ) !== '' ) {
-                       $wiki = "$dbName-$prefix";
-               } else {
-                       $wiki = $dbName;
-               }
                if ( $serverIndex === null || $refCount === null ) {
                        wfDebug( __METHOD__ . ": this connection was not opened as a foreign connection\n" );
 
@@ -516,6 +509,14 @@ class LoadBalancer {
 
                        return;
                }
+
+               $dbName = $conn->getDBname();
+               $prefix = $conn->tablePrefix();
+               if ( strval( $prefix ) !== '' ) {
+                       $wiki = "$dbName-$prefix";
+               } else {
+                       $wiki = $dbName;
+               }
                if ( $this->mConns['foreignUsed'][$serverIndex][$wiki] !== $conn ) {
                        throw new MWException( __METHOD__ . ": connection not found, has " .
                                "the connection been freed already?" );