From 900829b98664f675291a856bf0cbee70b0538d74 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 28 Jun 2012 20:14:39 +0000 Subject: [PATCH] Respect -1 as a memory limit setting. Don't override memory_limit = -1 with a fixed value. Know that WP_MEMORY_LIMIT = -1 can override a fixed value. props aaroncampbell fixes #14889 git-svn-id: https://develop.svn.wordpress.org/trunk@21165 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/default-constants.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/default-constants.php b/wp-includes/default-constants.php index 4e5daabd4d..476580c931 100644 --- a/wp-includes/default-constants.php +++ b/wp-includes/default-constants.php @@ -39,8 +39,11 @@ function wp_initial_constants( ) { $blog_id = 1; // set memory limits. - if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) ) - @ini_set('memory_limit', WP_MEMORY_LIMIT); + if ( function_exists( 'memory_get_usage' ) ) { + $current_limit = @ini_get( 'memory_limit' ); + if ( -1 != $current_limit && ( -1 == WP_MEMORY_LIMIT || ( inval( $current_limit ) < abs( intval( WP_MEMORY_LIMIT ) ) ) ) ) + @ini_set( 'memory_limit', WP_MEMORY_LIMIT ); + } if ( !defined('WP_CONTENT_DIR') ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down