From: Tim Starling Date: Sun, 21 Sep 2008 09:06:22 +0000 (+0000) Subject: More specific error messages X-Git-Tag: 1.31.0-rc.0~45182 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=cf6c94e5022e5af2f5b89688010191303a553244;p=lhc%2Fweb%2Fwiklou.git More specific error messages --- 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