From d4675054cdbbec4024b77546babd480c5813f111 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 17 Jan 2012 13:29:42 +0000 Subject: [PATCH] Fixed reading from file from r108774 --- maintenance/sql.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 ); -- 2.20.1