[wp-trac] [WordPress Trac] #14889: Memory Comparison Broken / WordPress Memory Limit

WordPress Trac wp-trac at lists.automattic.com
Mon Sep 27 08:42:42 UTC 2010

#14889: Memory Comparison Broken / WordPress Memory Limit
 Reporter:  hakre         |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  3.0            
 Severity:  normal        |    Keywords:  has-patch      

Comment(by dd32):

 > dd32 I think you have not understood the problem.

 I have understood it quite fine. The memory settings are assumed to be in
 Megabytes, (int) of such PHP Memory strings will result in the Integer
 fraction of the string to be returned. PHP 5.1+ allows for Gigabyte memory
 strings, As such, WordPress cannot assume it to be in M.

 PHP Memory limits being expressed in kilobytes however, Is pure madness,
 Including that check here seems like it'll be a waste of time.. Remember,
 this is code that is run on every pageload as part of the bootstrap, The
 less operations needed the better.

 > So with your life making easier suggestion you must add as well, that
 server admins must configure the memory limit with the M shorthand

 No, My mention that was the PHP memory limits should be checked for G,
 however, WP_MEMORY_LIMIT (Which 'we' (as WordPress) have have the _choice_
 to decide how it's defined) Presiously it has mearly been taken to be the
 same as the php memory limit, However has only ever worked as being
 expressed in Megabytes, We can choose to continue that by explicitly
 requesting it be defined as such, If someone defines it as G we'll
 silently pass on it as (int)64MB(PHP) > (int)1G (WP_MEMORY_LIMIT)

 Its purely a thought for optimization and keeping the 2-line code as
 simple as possible.

 For various reasons, We've also removed anonymous functions elsewhere in
 code, This is another thing which I feel is effectively part of the
 changes that occur to the standards over time.. It may not be written as
 such, but it's something that has been moved towards.

 We also already have a function for converting PHP Size notations for use
 in the Uploads: wp_convert_hr_to_bytes() - wp-admin/includes/template.php
 - But still, I feel the use of that is overkill for a bootstrap function..
 You can over-engineer anything, but sometimes, a simple check is better.

Ticket URL: <http://core.trac.wordpress.org/ticket/14889#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list