testPngNativetZtxt requires zlib extension
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 28cc001..2292e31 100644 (file)
@@ -1235,11 +1235,15 @@ function wfLogProfilingData() {
  *
  * @param $key String
  * @param $count Int
+ * @return void
  */
 function wfIncrStats( $key, $count = 1 ) {
        global $wgStatsMethod;
 
        $count = intval( $count );
+       if ( $count == 0 ) {
+               return;
+       }
 
        if( $wgStatsMethod == 'udp' ) {
                global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgAggregateStatsID;
@@ -2437,7 +2441,7 @@ define( 'TS_ISO_8601_BASIC', 9 );
  * @param $outputtype Mixed: A timestamp in one of the supported formats, the
  *                    function will autodetect which format is supplied and act
  *                    accordingly.
- * @param $ts Mixed: the timestamp to convert or 0 for the current timestamp
+ * @param $ts Mixed: optional timestamp to convert, default 0 for the current time
  * @return Mixed: String / false The same date in the format specified in $outputtype or false
  */
 function wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) {
@@ -2767,12 +2771,13 @@ 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)
+ * @param $limits Array optional array with limits(filesize, memory, time, walltime)
  *                 this overwrites the global wgShellMax* limits.
  * @return string collected stdout as a string (trailing newlines stripped)
  */
 function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array() ) {
-       global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime;
+       global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime,
+               $wgMaxShellWallClockTime;
 
        static $disabled;
        if ( is_null( $disabled ) ) {
@@ -2820,14 +2825,19 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array
 
        if ( php_uname( 's' ) == 'Linux' ) {
                $time = intval ( isset($limits['time']) ? $limits['time'] : $wgMaxShellTime );
+               if ( isset( $limits['walltime'] ) ) {
+                       $wallTime = intval( $limits['walltime'] );
+               } elseif ( isset( $limits['time'] ) ) {
+                       $wallTime = $time;
+               } else {
+                       $wallTime = intval( $wgMaxShellWallClockTime );
+               }
                $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";
-                       if ( is_executable( $script ) ) {
-                               $cmd = '/bin/bash ' . escapeshellarg( $script ) . " $time $mem $filesize " . escapeshellarg( $cmd );
-                       }
+               if ( $time > 0 || $mem > 0 || $filesize > 0 || $wallTime > 0 ) {
+                       $cmd = '/bin/bash ' . escapeshellarg( "$IP/bin/ulimit5.sh" ) .
+                               " $time $mem $filesize $wallTime " . escapeshellarg( $cmd );
                }
        }
        wfDebug( "wfShellExec: $cmd\n" );