Stop using memory_limit as a virtual memory limit for shell processes. Use a separate...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 17 Jun 2006 10:21:55 +0000 (10:21 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 17 Jun 2006 10:21:55 +0000 (10:21 +0000)
includes/DefaultSettings.php
includes/GlobalFunctions.php

index d9af202..d1169a8 100644 (file)
@@ -2098,4 +2098,9 @@ $wgAllowTitlesInSVG = false;
  */
 $wgContentNamespaces = array( NS_MAIN );
 
+/**
+ * Maximum amount of virtual memory available to shell processes under linux, in KB. 
+ */
+$wgMaxShellMemory = 102400;
+
 ?>
index f691999..e8f721f 100644 (file)
@@ -1661,7 +1661,7 @@ function wfUrlProtocols() {
  * @return collected stdout as a string (trailing newlines stripped)
  */
 function wfShellExec( $cmd, &$retval=null ) {
-       global $IP;
+       global $IP, $wgMaxShellMemory;
        
        if( ini_get( 'safe_mode' ) ) {
                wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
@@ -1671,15 +1671,12 @@ function wfShellExec( $cmd, &$retval=null ) {
 
        if ( php_uname( 's' ) == 'Linux' ) {
                $time = ini_get( 'max_execution_time' );
-               $mem = ini_get( 'memory_limit' );
-               if( preg_match( '/^([0-9]+)[Mm]$/', trim( $mem ), $m ) ) {
-                       $mem = intval( $m[1] * (1024*1024) );
-               }
+               $mem = intval( $wgMaxShellMemory );
+
                if ( $time > 0 && $mem > 0 ) {
                        $script = "$IP/bin/ulimit.sh";
                        if ( is_executable( $script ) ) {
-                               $memKB = intval( $mem / 1024 );
-                               $cmd = escapeshellarg( $script ) . " $time $memKB $cmd";
+                               $cmd = escapeshellarg( $script ) . " $time $mem $cmd";
                        }
                }
        } elseif ( php_uname( 's' ) == 'Windows NT' ) {