$replicaDB = $this->getOption( 'replicadb', $this->getOption( 'slave', '' ) );
if ( $replicaDB === 'any' ) {
$index = DB_REPLICA;
- } elseif ( $replicaDB != '' ) {
+ } elseif ( $replicaDB !== '' ) {
$index = null;
$serverCount = $lb->getServerCount();
for ( $i = 0; $i < $serverCount; ++$i ) {
break;
}
}
- if ( $index === null ) {
+ if ( $index === null || $index === $lb->getWriterIndex() ) {
$this->fatalError( "No replica DB server configured with the name '$replicaDB'." );
}
} else {
return $this->sqlPrintResult( $res, $db );
} catch ( DBQueryError $e ) {
if ( $dieOnError ) {
- $this->fatalError( $e );
+ $this->fatalError( (string)$e );
} else {
- $this->error( $e );
+ $this->error( (string)$e );
}
}
return null;