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 "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
 } else {
 	print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". ";
-	$n = intval( $memlimit );
-	if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
-		$n = intval( $m[1] * (1024*1024) );
-	}
-	if( $n < 20*1024*1024 ) {
-		print "Attempting to raise limit to 20M... ";
-		if( false === ini_set( "memory_limit", "20M" ) ) {
+	global $wgMemoryLimit;
+	if( wfParseMemoryLimit( $memlimit ) < wfParseMemoryLimit( $wgMemoryLimit ) ) {
+		print "Attempting to raise limit to " . htmlspecialchars( $wgMemoryLimit ) . "... ";
+		if( false === ini_set( "memory_limit", $wgMemoryLimit ) ) {
 			print "failed.<br /><b>" . htmlspecialchars( $memlimit ) . " seems too low, installation may fail!</b>";
 		} else {
-			$conf->raiseMemory = true;
 			print "ok.";
 		}
 	}
@@ -1878,9 +1873,6 @@
 
 require_once( \"\$IP/includes/DefaultSettings.php\" );
 
-# If PHP's memory limit is very low, some operations may fail.
-" . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
-