Services: Convert PasswordReset's static to a const now HHVM is gone
[lhc/web/wiklou.git] / maintenance / sql.php
index 21d8b2d..e7988fe 100644 (file)
@@ -67,7 +67,7 @@ class MwSql extends Maintenance {
                $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 ) {
@@ -76,7 +76,7 @@ class MwSql extends Maintenance {
                                        break;
                                }
                        }
-                       if ( $index === null ) {
+                       if ( $index === null || $index === $lb->getWriterIndex() ) {
                                $this->fatalError( "No replica DB server configured with the name '$replicaDB'." );
                        }
                } else {
@@ -175,9 +175,9 @@ class MwSql extends Maintenance {
                        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;