From: Sam Reed Date: Tue, 17 Jan 2012 13:29:42 +0000 (+0000) Subject: Fixed reading from file from r108774 X-Git-Tag: 1.31.0-rc.0~25222 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=d4675054cdbbec4024b77546babd480c5813f111;p=lhc%2Fweb%2Fwiklou.git Fixed reading from file from r108774 --- diff --git a/maintenance/sql.php b/maintenance/sql.php index a5c7314de0..c4af630786 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -30,15 +30,20 @@ class MwSql extends Maintenance { } public function execute() { + $dbw = wfGetDB( DB_MASTER ); if ( $this->hasArg() ) { $fileName = $this->getArg(); $file = fopen( $fileName, 'r' ); - } else { - $file = $this->getStdin(); - } + if ( !$file ) { + $this->error( "Unable to open input file", true ); + } - if ( !$file ) { - $this->error( "Unable to open input file", true ); + $error = $dbw->sourceStream( $file, false, array( $this, 'sqlPrintResult' ) ); + if ( $error !== true ) { + $this->error( $error, true ); + } else { + exit( 0 ); + } } $useReadline = function_exists( 'readline_add_history' ) @@ -51,7 +56,6 @@ class MwSql extends Maintenance { readline_read_history( $historyFile ); } - $dbw = wfGetDB( DB_MASTER ); $wholeLine = ''; while ( ( $line = Maintenance::readconsole() ) !== false ) { $done = $dbw->streamStatementEnd( $wholeLine, $line );