From: Alexandre Emsenhuber Date: Sat, 15 Mar 2014 13:34:52 +0000 (+0100) Subject: Move variable definitions near to where they are used X-Git-Tag: 1.31.0-rc.0~16600^2 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=85a7f625de461a2aba166854fbd6dee41ddb0454;p=lhc%2Fweb%2Fwiklou.git Move variable definitions near to where they are used In LoadBalancer::reuseConnection(), if the condition "$serverIndex === null || $refCount === null" is met, then those variables will not be used. So only define them when they will readlly be used. Change-Id: Ifbd4131f40d3babe733b8723d0d29d39890bb309 --- diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 5f880d6696..de4c2f56a8 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -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?" );