Index: trunk/phase3/includes/db/LoadBalancer.php |
— | — | @@ -406,6 +406,12 @@ |
407 | 407 | global $wgDBtype; |
408 | 408 | wfProfileIn( __METHOD__ ); |
409 | 409 | |
| 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 | + |
410 | 416 | if ( $wiki === wfWikiID() ) { |
411 | 417 | $wiki = false; |
412 | 418 | } |
— | — | @@ -435,13 +441,13 @@ |
436 | 442 | # Operation-based index |
437 | 443 | if ( $i == DB_SLAVE ) { |
438 | 444 | $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 | + } |
441 | 451 | } |
442 | | - # Couldn't find a working server in getReaderIndex()? |
443 | | - if ( $i === false ) { |
444 | | - $this->reportConnectionError( $this->mErrorConnection ); |
445 | | - } |
446 | 452 | |
447 | 453 | # Now we have an explicit index into the servers array |
448 | 454 | $conn = $this->openConnection( $i, $wiki ); |