[wp-trac] [WordPress Trac] #14889: Memory Comparison Broken / WordPress Memory Limit
WordPress Trac
wp-trac at lists.automattic.com
Mon Jun 6 20:03:13 UTC 2011
#14889: Memory Comparison Broken / WordPress Memory Limit
-----------------------------------------------+---------------------------
Reporter: hakre | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
Component: General | Release
Severity: normal | Version: 3.0
Keywords: has-patch 3.2-early needs-testing | Resolution:
-----------------------------------------------+---------------------------
Comment (by aaroncampbell):
Just thought I'd throw my 2c in on how I usually translate memory numbers
like this.
{{{
$symbol = array('B', 'K', 'M', 'G');
$memory_limit *= pow(1024, array_search(strtoupper($unit), $symbol));
}}}
The advantage obviously being that its easily scalable just by adding (in
order) new memory labels to the $symbols array. I've used this method for
quite some time in my efficient related posts plugin. You can see the
actual code here: http://plugins.trac.wordpress.org/browser/efficient-
related-posts/trunk/efficient-related-posts.php#L624
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14889#comment:20>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list