Convert Maintenance to the new shell framework
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 18 Jan 2018 02:24:34 +0000 (18:24 -0800)
committerGergő Tisza <gtisza@wikimedia.org>
Wed, 4 Apr 2018 13:59:25 +0000 (13:59 +0000)
Change-Id: Ibec8a84071fdf061f9831b2964143d99464cd4cc

maintenance/Maintenance.php

index 0c79bd5..4d0af5f 100644 (file)
@@ -25,6 +25,7 @@
 require_once __DIR__ . '/../includes/PHPVersionCheck.php';
 wfEntryPointCheck( 'cli' );
 
+use MediaWiki\Shell\Shell;
 use Wikimedia\Rdbms\DBReplicationWaitError;
 
 /**
@@ -1592,12 +1593,12 @@ abstract class Maintenance {
                // something that can do the relevant syscalls. There are a few
                // options. Linux and Mac OS X both have "stty size" which does the
                // job directly.
-               $retval = false;
-               $size = wfShellExec( 'stty size', $retval );
-               if ( $retval !== 0 ) {
+               $result = Shell::command( 'stty', 'size' )
+                       ->execute();
+               if ( $result->getExitCode() !== 0 ) {
                        return $default;
                }
-               if ( !preg_match( '/^(\d+) (\d+)$/', $size, $m ) ) {
+               if ( !preg_match( '/^(\d+) (\d+)$/', $result->getStdout(), $m ) ) {
                        return $default;
                }
                return [ intval( $m[2] ), intval( $m[1] ) ];