Make clear that reportConnectionError() stops the code flow.
authorPlatonides <platonides@gmail.com>
Mon, 26 Nov 2012 21:41:52 +0000 (22:41 +0100)
committerPlatonides <platonides@gmail.com>
Mon, 26 Nov 2012 21:41:52 +0000 (22:41 +0100)
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

index 8d32d35..7e5feea 100644 (file)
@@ -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 */
        }
 
        /**