From: Jan Gerber Date: Mon, 16 Jul 2012 20:06:57 +0000 (-0700) Subject: add optional limits argument to wgShellExec X-Git-Tag: 1.31.0-rc.0~23026^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=2a02b44b59afe408f42b86e020228a92df71c3ab;p=lhc%2Fweb%2Fwiklou.git add optional limits argument to wgShellExec add optional limits argument to overwrite filesize, memory and time limits or a command executed with wfShellExec. Just having once size fits all $wgMaxShell* options is not good enough for tasks that take long or create large files (i.e. video transcoding) Change-Id: I54148907bfd103fd28aff69baae03437efcfe1ee --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 845a144ddb..35887a4b47 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2885,9 +2885,11 @@ function wfEscapeShellArg( ) { * (non-zero is usually failure) * @param $environ Array optional environment variables which should be * added to the executed command environment. + * @param $limits Array optional array with limits(filesize, memory, time) + * this overwrites the global wgShellMax* limits. * @return string collected stdout as a string (trailing newlines stripped) */ -function wfShellExec( $cmd, &$retval = null, $environ = array() ) { +function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array() ) { global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime; static $disabled; @@ -2935,9 +2937,9 @@ function wfShellExec( $cmd, &$retval = null, $environ = array() ) { $cmd = $envcmd . $cmd; if ( php_uname( 's' ) == 'Linux' ) { - $time = intval( $wgMaxShellTime ); - $mem = intval( $wgMaxShellMemory ); - $filesize = intval( $wgMaxShellFileSize ); + $time = intval ( isset($limits['time']) ? $limits['time'] : $wgMaxShellTime ); + $mem = intval ( isset($limits['memory']) ? $limits['memory'] : $wgMaxShellMemory ); + $filesize = intval ( isset($limits['filesize']) ? $limits['filesize'] : $wgMaxShellFileSize ); if ( $time > 0 && $mem > 0 ) { $script = "$IP/bin/ulimit4.sh";