dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update MediaWiki\quietCall() -> Wikimedia\quietCall()
[lhc/web/wiklou.git]
/
maintenance
/
sql.php
diff --git
a/maintenance/sql.php
b/maintenance/sql.php
index
cc976ed
..
dd05bbe
100644
(file)
--- a/
maintenance/sql.php
+++ b/
maintenance/sql.php
@@
-24,6
+24,10
@@
require_once __DIR__ . '/Maintenance.php';
require_once __DIR__ . '/Maintenance.php';
+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.
*
/**
* Maintenance script that sends SQL queries from the specified file to the database.
*
@@
-50,7
+54,7
@@
class MwSql extends Maintenance {
$wiki = $this->hasOption( 'wikidb' ) ? $this->getOption( 'wikidb' ) : false;
// Get the appropriate load balancer (for this wiki)
if ( $this->hasOption( 'cluster' ) ) {
$wiki = $this->hasOption( 'wikidb' ) ? $this->getOption( 'wikidb' ) : false;
// Get the appropriate load balancer (for this wiki)
if ( $this->hasOption( 'cluster' ) ) {
- $lb = wfGetLBFactory()->getExternalLB( $this->getOption( 'cluster' )
, $wiki
);
+ $lb = wfGetLBFactory()->getExternalLB( $this->getOption( 'cluster' ) );
} else {
$lb = wfGetLB( $wiki );
}
} else {
$lb = wfGetLB( $wiki );
}
@@
-68,16
+72,16
@@
class MwSql extends Maintenance {
}
}
if ( $index === null ) {
}
}
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;
}
}
} else {
$index = DB_MASTER;
}
- /** @var Database $db DB handle for the appropriate cluster/wiki */
+ /** @var
I
Database $db DB handle for the appropriate cluster/wiki */
$db = $lb->getConnection( $index, [], $wiki );
if ( $replicaDB != '' && $db->getLBInfo( 'master' ) !== null ) {
$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 ( $index === DB_MASTER ) {
@@
-88,12
+92,12
@@
class MwSql extends Maintenance {
if ( $this->hasArg( 0 ) ) {
$file = fopen( $this->getArg( 0 ), 'r' );
if ( !$file ) {
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 ) {
}
$error = $db->sourceStream( $file, null, [ $this, 'sqlPrintResult' ] );
if ( $error !== true ) {
- $this->
error( $error, true
);
+ $this->
fatalError( $error
);
} else {
exit( 0 );
}
} else {
exit( 0 );
}
@@
-137,7
+141,7
@@
class MwSql extends Maintenance {
}
if ( $historyFile ) {
# Delimiter is eated by streamStatementEnd, we add it
}
if ( $historyFile ) {
# Delimiter is eated by streamStatementEnd, we add it
- # up in the history (
bug 37
020)
+ # up in the history (
T39
020)
readline_add_history( $wholeLine . ';' );
readline_write_history( $historyFile );
}
readline_add_history( $wholeLine . ';' );
readline_write_history( $historyFile );
}
@@
-153,13
+157,17
@@
class MwSql extends Maintenance {
$res = $db->query( $line );
$this->sqlPrintResult( $res, $db );
} catch ( DBQueryError $e ) {
$res = $db->query( $line );
$this->sqlPrintResult( $res, $db );
} catch ( DBQueryError $e ) {
- $this->error( $e, $dieOnError );
+ if ( $dieOnError ) {
+ $this->fatalError( $e );
+ } else {
+ $this->error( $e );
+ }
}
}
/**
* Print the results, callback for $db->sourceStream()
}
}
/**
* Print the results, callback for $db->sourceStream()
- * @param ResultWrapper
$res The results object
+ * @param ResultWrapper
|bool $res
* @param IDatabase $db
*/
public function sqlPrintResult( $res, $db ) {
* @param IDatabase $db
*/
public function sqlPrintResult( $res, $db ) {
@@
-184,5
+192,5
@@
class MwSql extends Maintenance {
}
}
}
}
-$maintClass =
"MwSql"
;
+$maintClass =
MwSql::class
;
require_once RUN_MAINTENANCE_IF_MAIN;
require_once RUN_MAINTENANCE_IF_MAIN;