From: Platonides Date: Mon, 26 Nov 2012 21:41:52 +0000 (+0100) Subject: Make clear that reportConnectionError() stops the code flow. X-Git-Tag: 1.31.0-rc.0~21499^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=4250770aeeac9d0677c6901dd81d3c1f90375251;p=lhc%2Fweb%2Fwiklou.git Make clear that reportConnectionError() stops the code flow. Use it as if 'returning' a value for getConnection(). It doesn't make sense to sometimes add a return false and sometimes not. But it was confusing that it looked like wfProfileOut( __METHOD__ ); could be called twice. Change-Id: I09638a134fcc925410389660f85239e8aa16483e --- diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 8d32d35939..7e5feea44b 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -501,8 +501,7 @@ class LoadBalancer { if ( $i === false ) { $this->mLastError = 'No working slave server: ' . $this->mLastError; wfProfileOut( __METHOD__ ); - $this->reportConnectionError( $this->mErrorConnection ); - return false; + return $this->reportConnectionError( $this->mErrorConnection ); } } @@ -510,7 +509,7 @@ class LoadBalancer { $conn = $this->openConnection( $i, $wiki ); if ( !$conn ) { wfProfileOut( __METHOD__ ); - $this->reportConnectionError( $this->mErrorConnection ); + return $this->reportConnectionError( $this->mErrorConnection ); } wfProfileOut( __METHOD__ ); @@ -745,8 +744,9 @@ class LoadBalancer { } else { $server = $conn->getProperty( 'mServer' ); wfLogDBError( "Connection error: {$this->mLastError} ({$server})\n" ); - $conn->reportConnectionError( "{$this->mLastError} ({$server})" ); + $conn->reportConnectionError( "{$this->mLastError} ({$server})" ); // throws DBConnectionError } + return false; /* not reached */ } /**