use Wikimedia\Rdbms\ResultWrapper;
use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\DBQueryError;
/**
* Maintenance script that sends SQL queries from the specified file to the database.
}
}
if ( $index === null ) {
- $this->error( "No replica DB server configured with the name '$replicaDB'.", 1 );
+ $this->fatalError( "No replica DB server configured with the name '$replicaDB'." );
}
} else {
$index = DB_MASTER;
}
- /** @var Database $db DB handle for the appropriate cluster/wiki */
+ /** @var IDatabase $db DB handle for the appropriate cluster/wiki */
$db = $lb->getConnection( $index, [], $wiki );
if ( $replicaDB != '' && $db->getLBInfo( 'master' ) !== null ) {
- $this->error( "The server selected ({$db->getServer()}) is not a replica DB.", 1 );
+ $this->fatalError( "The server selected ({$db->getServer()}) is not a replica DB." );
}
if ( $index === DB_MASTER ) {
if ( $this->hasArg( 0 ) ) {
$file = fopen( $this->getArg( 0 ), 'r' );
if ( !$file ) {
- $this->error( "Unable to open input file", true );
+ $this->fatalError( "Unable to open input file" );
}
$error = $db->sourceStream( $file, null, [ $this, 'sqlPrintResult' ] );
if ( $error !== true ) {
- $this->error( $error, true );
+ $this->fatalError( $error );
} else {
exit( 0 );
}
$res = $db->query( $line );
$this->sqlPrintResult( $res, $db );
} catch ( DBQueryError $e ) {
- $this->error( $e, $dieOnError );
+ if ( $dieOnError ) {
+ $this->fatalError( $e );
+ } else {
+ $this->error( $e );
+ }
}
}