Fix sql.php behavior on error
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 10 Jul 2015 17:38:19 +0000 (13:38 -0400)
committerBryanDavis <bdavis@wikimedia.org>
Fri, 10 Jul 2015 17:55:44 +0000 (17:55 +0000)
When an erroneous query is entered into sql.php, it doesn't clear its
line buffer, so the intended next query (often fixing a typo in the
original) winds up concatenated onto the erroneous query. Usually
leading to another error, which repeats the process.

The solution is simple enough: clear the line buffer unconditionally,
not only when no exception is caught.

Change-Id: Ia78e2df8b9c6698c0a225bfb3135274ed8da5303

maintenance/sql.php

index 82eae21..a7fd827 100644 (file)
@@ -125,12 +125,12 @@ class MwSql extends Maintenance {
                        try {
                                $res = $db->query( $wholeLine );
                                $this->sqlPrintResult( $res, $db );
-                               $prompt = $newPrompt;
-                               $wholeLine = '';
                        } catch ( DBQueryError $e ) {
                                $doDie = !Maintenance::posix_isatty( 0 );
                                $this->error( $e, $doDie );
                        }
+                       $prompt = $newPrompt;
+                       $wholeLine = '';
                }
                wfWaitForSlaves();
        }