r109143 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109142‎ | r109143 | r109144 >
Date:13:29, 17 January 2012
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Fixed reading from file from r108774
Modified paths:
  • /trunk/phase3/maintenance/sql.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/sql.php
@@ -30,15 +30,20 @@
3131 }
3232
3333 public function execute() {
 34+ $dbw = wfGetDB( DB_MASTER );
3435 if ( $this->hasArg() ) {
3536 $fileName = $this->getArg();
3637 $file = fopen( $fileName, 'r' );
37 - } else {
38 - $file = $this->getStdin();
39 - }
 38+ if ( !$file ) {
 39+ $this->error( "Unable to open input file", true );
 40+ }
4041
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+ }
4348 }
4449
4550 $useReadline = function_exists( 'readline_add_history' )
@@ -51,7 +56,6 @@
5257 readline_read_history( $historyFile );
5358 }
5459
55 - $dbw = wfGetDB( DB_MASTER );
5660 $wholeLine = '';
5761 while ( ( $line = Maintenance::readconsole() ) !== false ) {
5862 $done = $dbw->streamStatementEnd( $wholeLine, $line );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108774Give sql.php eval.php type scrollbackreedy22:57, 12 January 2012

Comments

#Comment by 😂 (talk | contribs)   14:14, 17 January 2012

This also gets rid of stdin, but I suppose that's acceptable.

#Comment by Reedy (talk | contribs)   14:16, 17 January 2012

Indeed, the other way would be to keep it, and have some parameter to have it as a CLI with backscroll like eval

Status & tagging log