r41093 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41092‎ | r41093 | r41094 >
Date:09:06, 21 September 2008
Author:tstarling
Status:old
Tags:
Comment:
More specific error messages
Modified paths:
  • /trunk/phase3/includes/db/LoadBalancer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/LoadBalancer.php
@@ -406,6 +406,12 @@
407407 global $wgDBtype;
408408 wfProfileIn( __METHOD__ );
409409
 410+ if ( $i == DB_LAST ) {
 411+ throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' );
 412+ } elseif ( $i === null || $i === false ) {
 413+ throw new MWException( 'Attempt to call ' . __METHOD__ . ' with invalid server index' );
 414+ }
 415+
410416 if ( $wiki === wfWikiID() ) {
411417 $wiki = false;
412418 }
@@ -435,13 +441,13 @@
436442 # Operation-based index
437443 if ( $i == DB_SLAVE ) {
438444 $i = $this->getReaderIndex( false, $wiki );
439 - } elseif ( $i == DB_LAST ) {
440 - throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' );
 445+ # Couldn't find a working server in getReaderIndex()?
 446+ if ( $i === false ) {
 447+ $this->mLastError = 'No working slave server: ' . $this->mLastError;
 448+ $this->reportConnectionError( $this->mErrorConnection );
 449+ return false;
 450+ }
441451 }
442 - # Couldn't find a working server in getReaderIndex()?
443 - if ( $i === false ) {
444 - $this->reportConnectionError( $this->mErrorConnection );
445 - }
446452
447453 # Now we have an explicit index into the servers array
448454 $conn = $this->openConnection( $i, $wiki );

Follow-up revisions

RevisionCommit summaryAuthorDate
r41234Revert some recent ES-related changes -- they made behavior much worse when w...brion18:09, 24 September 2008