X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=4d0af5fa78f21de38cd59f03cc0e96845bc767f4;hb=6c169ee1fd84dcf82596edc8c696eff40f2b9aed;hp=617071b25fc2b680e39613cdf780b0b95f4bbf8f;hpb=c1edd28ba660411ecc4207533d522926c82913fc;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 617071b25f..4d0af5fa78 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; /** @@ -514,6 +515,8 @@ abstract class Maintenance { "http://en.wikipedia.org. This is sometimes necessary because " . "server name detection may fail in command line scripts.", false, true ); $this->addOption( 'profiler', 'Profiler output format (usually "text")', false, true ); + // This is named --mwdebug, because --debug would conflict in the phpunit.php CLI script. + $this->addOption( 'mwdebug', 'Enable built-in MediaWiki development settings', false, true ); # Save generic options to display them separately in help $this->mGenericParameters = $this->mParams; @@ -676,7 +679,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 @@ -713,8 +716,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 ); @@ -1009,7 +1010,7 @@ abstract class Maintenance { // ... append parameters ... if ( $this->mParams ) { - $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]"; + $output .= " [--" . implode( "|--", array_keys( $this->mParams ) ) . "]"; } // ... and append arguments. @@ -1149,6 +1150,11 @@ abstract class Maintenance { MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->destroy(); } + # Apply debug settings + if ( $this->hasOption( 'mwdebug' ) ) { + require __DIR__ . '/../includes/DevelopmentSettings.php'; + } + // Per-script profiling; useful for debugging $this->activateProfiler(); @@ -1287,7 +1293,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 */ @@ -1587,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] ) ];