Fix SQLite patch-(page|template)links-fix-pk.sql column order
[lhc/web/wiklou.git] / maintenance / mysql.php
index 6d0882a..c1e403c 100644 (file)
@@ -72,8 +72,6 @@ class MysqlMaintenance extends Maintenance {
                        $host = $this->getOption( 'host' );
                        $serverCount = $lb->getServerCount();
                        for ( $index = 0; $index < $serverCount; ++$index ) {
-                               $serverInfo = $lb->getServerInfo( $index );
-
                                if ( $lb->getServerName( $index ) === $host ) {
                                        break;
                                }
@@ -106,9 +104,9 @@ class MysqlMaintenance extends Maintenance {
         * Run the mysql client for the given server info
         *
         * @param array $info
-        * @param string|false The DB name, or false to use the main wiki DB
+        * @param string|false $dbName The DB name, or false to use the main wiki DB
         *
-        * @return The desired exit status
+        * @return int The desired exit status
         */
        private function runMysql( $info, $dbName ) {
                // Write the password to an option file to avoid disclosing it to other
@@ -139,9 +137,7 @@ class MysqlMaintenance extends Maintenance {
                } elseif ( substr_count( $realServer, ':' ) == 1 ) {
                        // If we have a colon and something that's not a port number
                        // inside the hostname, assume it's the socket location
-                       $hostAndSocket = explode( ':', $realServer, 2 );
-                       $realServer = $hostAndSocket[0];
-                       $socket = $hostAndSocket[1];
+                       list( $realServer, $socket ) = explode( ':', $realServer, 2 );
                }
 
                if ( $dbName === false ) {
@@ -165,6 +161,12 @@ class MysqlMaintenance extends Maintenance {
 
                $args = array_merge( $args, $this->mArgs );
 
+               // Ignore SIGINT if possible, otherwise the wrapper terminates when the user presses
+               // ctrl-C to kill a query.
+               if ( function_exists( 'pcntl_signal' ) ) {
+                       pcntl_signal( SIGINT, SIG_IGN );
+               }
+
                $pipes = [];
                $proc = proc_open( Shell::escape( $args ), $desc, $pipes );
                if ( $proc === false ) {