From cf6c94e5022e5af2f5b89688010191303a553244 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 21 Sep 2008 09:06:22 +0000 Subject: [PATCH] More specific error messages --- includes/db/LoadBalancer.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index d0a7343d03..d92ded838d 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -406,6 +406,12 @@ class LoadBalancer { global $wgDBtype; wfProfileIn( __METHOD__ ); + if ( $i == DB_LAST ) { + throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' ); + } elseif ( $i === null || $i === false ) { + throw new MWException( 'Attempt to call ' . __METHOD__ . ' with invalid server index' ); + } + if ( $wiki === wfWikiID() ) { $wiki = false; } @@ -435,12 +441,12 @@ class LoadBalancer { # Operation-based index if ( $i == DB_SLAVE ) { $i = $this->getReaderIndex( false, $wiki ); - } elseif ( $i == DB_LAST ) { - throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' ); - } - # Couldn't find a working server in getReaderIndex()? - if ( $i === false ) { - $this->reportConnectionError( $this->mErrorConnection ); + # Couldn't find a working server in getReaderIndex()? + if ( $i === false ) { + $this->mLastError = 'No working slave server: ' . $this->mLastError; + $this->reportConnectionError( $this->mErrorConnection ); + return false; + } } # Now we have an explicit index into the servers array -- 2.20.1