From 85a7f625de461a2aba166854fbd6dee41ddb0454 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 15 Mar 2014 14:34:52 +0100 Subject: [PATCH] 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 --- includes/db/LoadBalancer.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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?" ); -- 2.20.1