Index: includes/GlobalFunctions.php =================================================================== --- includes/GlobalFunctions.php (revision 53388) +++ includes/GlobalFunctions.php (working copy) @@ -3180,3 +3180,11 @@ return $array; } + +/* Parse PHP's silly format for memory limits */ +function wfParseMemoryLimit( $memlimit ) { + $n = intval( $memlimit ); + if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) { + $n = intval( $m[1] * (1024*1024) ); + } + return $n; +} Index: includes/Setup.php =================================================================== --- includes/Setup.php (revision 53388) +++ includes/Setup.php (working copy) @@ -149,8 +149,15 @@ require_once( "$IP/includes/StubObject.php" ); wfProfileOut( $fname.'-includes' ); wfProfileIn( $fname.'-misc1' ); +# Raise the memory limit if it's too low +global $wgMemoryLimit; +$memlimit = ini_get( "memory_limit" ); +if( !( empty( $memlimit ) || $memlimit == -1 ) ) { + if( wfParseMemoryLimit( $memlimit ) < wfParseMemoryLimit( $wgMemoryLimit ) ) { + wfDebug( "\n\nRaise PHP's memory limit from $memlimit to $wgMemoryLimit\n" ); + ini_set( "memory_limit", $wgMemoryLimit ); + } +} Index: includes/DefaultSettings.php =================================================================== --- includes/DefaultSettings.php (revision 53388) +++ includes/DefaultSettings.php (working copy) @@ -4021,3 +4021,8 @@ * ); */ $wgPoolCounterConf = null; + +/** + * The minimum amount of memory that MediaWiki "needs"; MediaWiki will try to raise PHP's memory limit if it's below this amount. + */ +$wgMemoryLimit = "50M"; Index: config/index.php =================================================================== --- config/index.php (revision 53388) +++ config/index.php (working copy) @@ -466,21 +466,16 @@ Perl-compatible regular expression functions." ); $memlimit = ini_get( "memory_limit" ); -$conf->raiseMemory = false; if( empty( $memlimit ) || $memlimit == -1 ) { print "