From 4250770aeeac9d0677c6901dd81d3c1f90375251 Mon Sep 17 00:00:00 2001 From: Platonides Date: Mon, 26 Nov 2012 22:41:52 +0100 Subject: [PATCH] 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 --- includes/db/LoadBalancer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 */ } /** -- 2.20.1