X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=cb95fa7ca2ad7843f11727a6d53be3ae03bb9ae8;hp=7e4bf7c043f461400b6a34a76d32334330d1cf5f;hb=4ff20403580e14aa301729f414fe170ef846f596;hpb=e46d0694ac253df5f91fcfcd65ff19b0b3a2982c diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 7e4bf7c043..cb95fa7ca2 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -25,6 +25,7 @@ require_once __DIR__ . '/../includes/PHPVersionCheck.php'; wfEntryPointCheck( 'cli' ); +use MediaWiki\Shell\Shell; use Wikimedia\Rdbms\DBReplicationWaitError; /** @@ -34,6 +35,10 @@ use Wikimedia\Rdbms\DBReplicationWaitError; // Define this so scripts can easily find doMaintenance.php define( 'RUN_MAINTENANCE_IF_MAIN', __DIR__ . '/doMaintenance.php' ); + +/** + * @deprecated since 1.31 + */ define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless $maintClass = false; @@ -508,7 +513,9 @@ abstract class Maintenance { $this->addOption( 'memory-limit', 'Set a specific memory limit for the script, ' - . '"max" for no limit or "default" to avoid changing it' + . '"max" for no limit or "default" to avoid changing it', + false, + true ); $this->addOption( 'server', "The protocol and server name to use in URLs, e.g. " . "http://en.wikipedia.org. This is sometimes necessary because " . @@ -678,7 +685,7 @@ abstract class Maintenance { * Do some sanity checking and basic setup */ public function setup() { - global $IP, $wgCommandLineMode, $wgRequestTime; + global $IP, $wgCommandLineMode; # Abort if called from a web server # wfIsCLI() is not available yet @@ -715,8 +722,6 @@ abstract class Maintenance { # But sometimes this doesn't seem to be the case. ini_set( 'max_execution_time', 0 ); - $wgRequestTime = microtime( true ); - # Define us as being in MediaWiki define( 'MEDIAWIKI', true ); @@ -1011,7 +1016,7 @@ abstract class Maintenance { // ... append parameters ... if ( $this->mParams ) { - $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]"; + $output .= " [--" . implode( "|--", array_keys( $this->mParams ) ) . "]"; } // ... and append arguments. @@ -1294,7 +1299,7 @@ abstract class Maintenance { * This function has the same parameters as wfGetDB() * * @param int $db DB index (DB_REPLICA/DB_MASTER) - * @param array $groups default: empty array + * @param string|string[] $groups default: empty array * @param string|bool $wiki default: current wiki * @return IMaintainableDatabase */ @@ -1594,12 +1599,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] ) ];