Make WordPress Core

Opened 8 years ago

Closed 3 weeks ago

Last modified 3 weeks ago

#36426 closed enhancement (fixed)

WP Admin memory limit not increasing to base limit by default

Reported by: eclare's profile eclare Owned by: pbearne's profile pbearne
Milestone: 6.7 Priority: normal
Severity: normal Version: 4.6
Component: Administration Keywords: has-patch
Focuses: administration, performance Cc:

Description

We have 2 constants that can be set in wp-config.php (and by using filters, afaik), for example:

define( 'WP_MEMORY_LIMIT', '512M' ); // increases WP base (front-end) limit
define( 'WP_MAX_MEMORY_LIMIT', '512M'); // increases WP admin (back-end) limit

The former isn't really known, which you can Google to find out. People usually only use the first constant.
If the 2nd constant (WP_MAX_MEMORY_LIMIT) is not set, it defaults to 256M. WP_MEMORY_LIMIT can be higher than that though, so we could safely increase WP_MAX_MEMORY_LIMIT to match WP_MEMORY_LIMIT if WP_MEMORY_LIMIT is higher and WP_MAX_MEMORY_LIMIT is not set manually to a lower (than WP_MEMORY_LIMIT) value.

What I mean in coding terms:

if(!isset(WP_MAX_MEMORY_LIMIT) && isset(WP_MEMORY_LIMIT)){
    if(WP_MEMORY_LIMIT>DEFAULT_WP_MAX_MEMORY_LIMIT){
    //NOTE to the line above: this requires parsing the actual value in these constants as the strings can be like: 512M, 1G etc.; the DEFAULT_WP_MAX_MEMORY_LIMIT is a thing I came up with, currently the default admin memory limit is 256M
        define( 'WP_MAX_MEMORY_LIMIT', WP_MEMORY_LIMIT);
    }
}

All these values can be checked with the Bulletproof Security plugin, under BPS Security -> System Info.
Side note: imho WP_MAX_MEMORY_LIMIT should be renamed to something like WP_ADMIN_MEMORY_LIMIT, but that's another issue.

Attachments (1)

36426.diff (1.4 KB) - added by dd32 8 years ago.

Download all attachments as: .zip

Change History (10)

@dd32
8 years ago

#1 @dd32
8 years ago

  • Keywords has-patch added

This seems like a sane enough change to me.

36426.diff sets WP_MAX_MEMORY_LIMIT to WP_MEMORY_LIMIT in the event that WP_MEMORY_LIMIT is > 256M.

#2 @eclare
8 years ago

Code looks good to me, but I'm no core dev. Thanks!

This ticket was mentioned in PR #6414 on WordPress/wordpress-develop by @pbearne.


5 months ago
#3

The code for setting the WP_MAX_MEMORY_LIMIT has been tweaked. If the defined WP_MEMORY_LIMIT in bytes is greater than 256M, WP_MAX_MEMORY_LIMIT will now be set to the value of WP_MEMORY_LIMIT instead of the current memory limit. This adjustment provides a more precise control of the memory limit.

#4 @pbearne
5 months ago

  • Owner set to pbearne
  • Status changed from new to assigned

refreshed

#5 @pbearne
2 months ago

  • Milestone set to 6.7

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


2 months ago

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


7 weeks ago

#8 @flixos90
3 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 58937:

Administration: Avoid using WP_MAX_MEMORY_LIMIT default that is smaller than WP_MEMORY_LIMIT.

Props eclare, dd32, pbearne.
Fixes #36426.

Note: See TracTickets for help on using tickets.