Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3193,6 +3193,15 @@ |
3194 | 3194 | return $array; |
3195 | 3195 | } |
3196 | 3196 | |
| 3197 | +/* Parse PHP's silly format for memory limits */ |
| 3198 | +function wfParseMemoryLimit( $memlimit ) { |
| 3199 | + $n = intval( $memlimit ); |
| 3200 | + if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) { |
| 3201 | + $n = intval( $m[1] * (1024*1024) ); |
| 3202 | + } |
| 3203 | + return $n; |
| 3204 | +} |
| 3205 | + |
3197 | 3206 | /* Get the normalised IETF language tag |
3198 | 3207 | * @param $code String: The language code. |
3199 | 3208 | * @return $langCode String: The language code which complying with BCP 47 standards. |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -149,8 +149,16 @@ |
150 | 150 | require_once( "$IP/includes/StubObject.php" ); |
151 | 151 | wfProfileOut( $fname.'-includes' ); |
152 | 152 | wfProfileIn( $fname.'-misc1' ); |
| 153 | +# Raise the memory limit if it's too low |
| 154 | +global $wgMemoryLimit; |
| 155 | +$memlimit = ini_get( "memory_limit" ); |
| 156 | +if( !( empty( $memlimit ) || $memlimit == -1 ) ) { |
| 157 | + if( wfParseMemoryLimit( $memlimit ) < wfParseMemoryLimit( $wgMemoryLimit ) ) { |
| 158 | + wfDebug( "\n\nRaise PHP's memory limit from $memlimit to $wgMemoryLimit\n" ); |
| 159 | + ini_set( "memory_limit", $wgMemoryLimit ); |
| 160 | + } |
| 161 | +} |
153 | 162 | |
154 | | - |
155 | 163 | $wgIP = false; # Load on demand |
156 | 164 | # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor |
157 | 165 | $wgRequest = new WebRequest; |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4151,3 +4151,8 @@ |
4152 | 4152 | */ |
4153 | 4153 | $wgCrossSiteAJAXdomainsRegex = false; |
4154 | 4154 | |
| 4155 | +/** |
| 4156 | + * The minimum amount of memory that MediaWiki "needs"; MediaWiki will try to raise PHP's memory limit if it's below this amount. |
| 4157 | + */ |
| 4158 | +$wgMemoryLimit = "50M"; |
| 4159 | + |
Index: trunk/phase3/config/index.php |
— | — | @@ -466,21 +466,16 @@ |
467 | 467 | Perl-compatible regular expression functions." ); |
468 | 468 | |
469 | 469 | $memlimit = ini_get( "memory_limit" ); |
470 | | -$conf->raiseMemory = false; |
471 | 470 | if( empty( $memlimit ) || $memlimit == -1 ) { |
472 | 471 | print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n"; |
473 | 472 | } else { |
474 | 473 | print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". "; |
475 | | - $n = intval( $memlimit ); |
476 | | - if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) { |
477 | | - $n = intval( $m[1] * (1024*1024) ); |
478 | | - } |
479 | | - if( $n < 20*1024*1024 ) { |
480 | | - print "Attempting to raise limit to 20M... "; |
481 | | - if( false === ini_set( "memory_limit", "20M" ) ) { |
| 474 | + global $wgMemoryLimit; |
| 475 | + if( wfParseMemoryLimit( $memlimit ) < wfParseMemoryLimit( $wgMemoryLimit ) ) { |
| 476 | + print "Attempting to raise limit to " . htmlspecialchars( $wgMemoryLimit ) . "... "; |
| 477 | + if( false === ini_set( "memory_limit", $wgMemoryLimit ) ) { |
482 | 478 | print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>"; |
483 | 479 | } else { |
484 | | - $conf->raiseMemory = true; |
485 | 480 | print "ok."; |
486 | 481 | } |
487 | 482 | } |
— | — | @@ -1890,9 +1885,6 @@ |
1891 | 1886 | |
1892 | 1887 | require_once( \"\$IP/includes/DefaultSettings.php\" ); |
1893 | 1888 | |
1894 | | -# If PHP's memory limit is very low, some operations may fail. |
1895 | | -" . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . " |
1896 | | - |
1897 | 1889 | if ( \$wgCommandLineMode ) { |
1898 | 1890 | if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) { |
1899 | 1891 | die( \"This script must be run from the command line\\n\" ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | * (bug 19907) $wgCrossSiteAJAXdomains and $wgCrossSiteAJAXdomainsRegex added |
81 | 81 | to control which external domains may access the API via cross-site AJAX. |
82 | 82 | * $wgMaintenanceScripts for extensions to add their scripts to the default list |
| 83 | +* $wgMemoryLimit has been added, default value '50M' |
83 | 84 | |
84 | 85 | === New features in 1.16 === |
85 | 86 | |
— | — | @@ -386,6 +387,7 @@ |
387 | 388 | style that specifies the media attribute as screen. This is done to resolve |
388 | 389 | and issue with Opera (bug 18497) where fullscreen mode is assumed to be |
389 | 390 | projection mode and the style sheet for screen media is no longer used. |
| 391 | +* (bug 16084) Default memory limit has be increased to 50M, see $wgMemoryLimit |
390 | 392 | |
391 | 393 | == API changes in 1.16 == |
392 | 394 | |