Index: trunk/phase3/maintenance/sql.php |
— | — | @@ -30,15 +30,20 @@ |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function execute() { |
| 34 | + $dbw = wfGetDB( DB_MASTER ); |
34 | 35 | if ( $this->hasArg() ) { |
35 | 36 | $fileName = $this->getArg(); |
36 | 37 | $file = fopen( $fileName, 'r' ); |
37 | | - } else { |
38 | | - $file = $this->getStdin(); |
39 | | - } |
| 38 | + if ( !$file ) { |
| 39 | + $this->error( "Unable to open input file", true ); |
| 40 | + } |
40 | 41 | |
41 | | - if ( !$file ) { |
42 | | - $this->error( "Unable to open input file", true ); |
| 42 | + $error = $dbw->sourceStream( $file, false, array( $this, 'sqlPrintResult' ) ); |
| 43 | + if ( $error !== true ) { |
| 44 | + $this->error( $error, true ); |
| 45 | + } else { |
| 46 | + exit( 0 ); |
| 47 | + } |
43 | 48 | } |
44 | 49 | |
45 | 50 | $useReadline = function_exists( 'readline_add_history' ) |
— | — | @@ -51,7 +56,6 @@ |
52 | 57 | readline_read_history( $historyFile ); |
53 | 58 | } |
54 | 59 | |
55 | | - $dbw = wfGetDB( DB_MASTER ); |
56 | 60 | $wholeLine = ''; |
57 | 61 | while ( ( $line = Maintenance::readconsole() ) !== false ) { |
58 | 62 | $done = $dbw->streamStatementEnd( $wholeLine, $line ); |