diff options
author | Max Semenik <maxsem.wiki@gmail.com> | 2017-09-08 23:10:09 -0700 |
---|---|---|
committer | Max Semenik <maxsem.wiki@gmail.com> | 2017-10-03 20:01:59 -0700 |
commit | 1bb9a223d268518cedc16cfe4d67a293989d7aa5 (patch) | |
tree | c76d70fd0077b6005c928b30f7d8de8fc697b312 /includes/shell/Shell.php | |
parent | f5f817fc58bf429a48fac1b9a7fb7ad642e3f9f2 (diff) | |
download | mediawikicore-1bb9a223d268518cedc16cfe4d67a293989d7aa5.tar.gz mediawikicore-1bb9a223d268518cedc16cfe4d67a293989d7aa5.zip |
Inject dependencies into Shell\Command
This slightly changes how execution time limits fall back on each other.
Change-Id: I7754a9e6be9638eebe90cb953adb8e2a6ee97cef
Diffstat (limited to 'includes/shell/Shell.php')
-rw-r--r-- | includes/shell/Shell.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/includes/shell/Shell.php b/includes/shell/Shell.php index c293ff2110eb..f2c96aeb994f 100644 --- a/includes/shell/Shell.php +++ b/includes/shell/Shell.php @@ -22,6 +22,9 @@ namespace MediaWiki\Shell; +use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; + /** * Executes shell commands * @@ -39,10 +42,10 @@ namespace MediaWiki\Shell; class Shell { /** - * Returns a new instance of this class + * Returns a new instance of Command class * - * @param string|string[] $command If string, a properly shell-escaped command line, - * or an array of unescaped arguments, in which case each value will be escaped + * @param string|string[] $command String or array of strings representing the command to + * be executed, each value will be escaped. * Example: [ 'convert', '-font', 'font name' ] would produce "'convert' '-font' 'font name'" * @return Command */ @@ -54,6 +57,18 @@ class Shell { $args = reset( $args ); } $command = new Command(); + $config = MediaWikiServices::getInstance()->getMainConfig(); + + $limits = [ + 'time' => $config->get( 'MaxShellTime' ), + 'walltime' => $config->get( 'MaxShellWallClockTime' ), + 'memory' => $config->get( 'MaxShellMemory' ), + 'filesize' => $config->get( 'MaxShellFileSize' ), + ]; + $command->limits( $limits ); + $command->cgroup( $config->get( 'ShellCgroup' ) ); + $command->setLogger( LoggerFactory::getInstance( 'exec' ) ); + return $command->params( $args ); } |