[wp-trac] [WordPress Trac] #32075: Only set WP_MAX_MEMORY_LIMIT by default when its greater than memory_limit

WordPress Trac noreply at wordpress.org
Sun Apr 10 14:01:19 UTC 2016


#32075: Only set WP_MAX_MEMORY_LIMIT by default when its greater than memory_limit
------------------------------------+-----------------------------
 Reporter:  danielbachhuber         |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Future Release
Component:  Bootstrap/Load          |     Version:  3.2
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+-----------------------------

Comment (by jrf):

 > As for now WP_MAX_MEMORY_LIMIT is simply set to 256M by default. There
 is no verification whether it is really possible to set this value.

 As the constant can be set in `wp-config.php` as well, this is - IMHO -
 not really in the scope of this issue. The WP_MAX_MEMORY_LIMIT is a
 ''*target*'' value, not a definite.

 > Plugins like WooCommerce "report" this value in the backend on a status
 page and a user is told "the memory is ok".
 >
 > You are absolutely correct a developer should never ever rely on any
 constant. But as you can see it is done. Not in the means of a
 "dependency" but in the means of reported "unchecked and unfiltered".
 Reporting something to the user that isn't true and may complicate the
 troubleshooting is simply spoken wrong.

 It's useful information if presented properly. The fact that WooCommerce
 apparently presents it with the presumption that the actual setting will
 always succeed is wrong. However, that is more of a plugin developer
 education issue which is again - IMHO - outside of the scope of this
 issue.

 > Imho you have to get the allocated memory first, than try to increase it
 to 256M. If the return value is true you can define WP_MAX_MEMORY_LIMIT to
 256M otherwise you set it to the currently allocated memory.

 The constant only provides the target value and - again - as this can also
 be set in `wp-config.php`, validation of whether the target value is
 realistic is not in the scope of this issue. This issue is about making
 sure it's never ''*lower*'' than the ''*current* '' memory limit.

 The actual raising of the memory is only needed/done in WP in two
 particular circumstances at this moment and normally not needed. Doing so
 and then reverting on every page load just to try to get a more realistic
 target constant seems superfluous to me.

 > In today's hosting environments you will find PHP-FPM very often and
 there it is easy to restrict the memory allocation by defining it with
 php_admin_value[memory_limit] instead of php_value[memory_limit].

 Good point and that is actually something I can work with, though it won't
 be fool-proof (re: setting of constant in`wp-config.php`). Let me see what
 I can come up with on that end.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32075#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list