r54339 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54338‎ | r54339 | r54340 >
Date:02:47, 4 August 2009
Author:demon
Status:resolved (Comments)
Tags:
Comment:
(bug 16084) Default memory limit should be increased
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/config/index.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3193,6 +3193,15 @@
31943194 return $array;
31953195 }
31963196
 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+
31973206 /* Get the normalised IETF language tag
31983207 * @param $code String: The language code.
31993208 * @return $langCode String: The language code which complying with BCP 47 standards.
Index: trunk/phase3/includes/Setup.php
@@ -149,8 +149,16 @@
150150 require_once( "$IP/includes/StubObject.php" );
151151 wfProfileOut( $fname.'-includes' );
152152 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+}
153162
154 -
155163 $wgIP = false; # Load on demand
156164 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
157165 $wgRequest = new WebRequest;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4151,3 +4151,8 @@
41524152 */
41534153 $wgCrossSiteAJAXdomainsRegex = false;
41544154
 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 @@
467467 Perl-compatible regular expression functions." );
468468
469469 $memlimit = ini_get( "memory_limit" );
470 -$conf->raiseMemory = false;
471470 if( empty( $memlimit ) || $memlimit == -1 ) {
472471 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
473472 } else {
474473 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 ) ) {
482478 print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
483479 } else {
484 - $conf->raiseMemory = true;
485480 print "ok.";
486481 }
487482 }
@@ -1890,9 +1885,6 @@
18911886
18921887 require_once( \"\$IP/includes/DefaultSettings.php\" );
18931888
1894 -# If PHP's memory limit is very low, some operations may fail.
1895 -" . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1896 -
18971889 if ( \$wgCommandLineMode ) {
18981890 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
18991891 die( \"This script must be run from the command line\\n\" );
Index: trunk/phase3/RELEASE-NOTES
@@ -79,6 +79,7 @@
8080 * (bug 19907) $wgCrossSiteAJAXdomains and $wgCrossSiteAJAXdomainsRegex added
8181 to control which external domains may access the API via cross-site AJAX.
8282 * $wgMaintenanceScripts for extensions to add their scripts to the default list
 83+* $wgMemoryLimit has been added, default value '50M'
8384
8485 === New features in 1.16 ===
8586
@@ -386,6 +387,7 @@
387388 style that specifies the media attribute as screen. This is done to resolve
388389 and issue with Opera (bug 18497) where fullscreen mode is assumed to be
389390 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
390392
391393 == API changes in 1.16 ==
392394

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45361(bug 16084) Default memory limit should be increasedaaron06:00, 3 January 2009
r45475Revert r45361 for now "(bug 16084) Default memory limit should be increased"...brion01:42, 7 January 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   22:34, 4 August 2009

If the memory limit is below what we want but ini_set is disabled, this will throw a warning on every run:

+		ini_set( "memory_limit", $wgMemoryLimit );
#Comment by Emufarmers (talk | contribs)   23:04, 4 August 2009

Fixed in r54405 and r54406.

Status & tagging log