Permalink
Browse files

BUG: Fix increase_memory_limit_to() to reduce installation errors.

increase_memory_limit_to() was broken a while ago, and this causes a lot of problems for people trying to install on environments where the memory limit is 32M.
  • Loading branch information...
1 parent 2a3d387 commit 6ef4f9ad3fafb3ecce93bf6f49270cf6960ce597 @sminnee sminnee committed Jun 26, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 core/Core.php
View
@@ -409,7 +409,8 @@ function increase_memory_limit_to($memoryLimit = -1) {
// Check hard maximums
$max = get_increase_memory_limit_max();
- if($max != -1 && translate_memstring($memoryLimit) > translate_memstring($max)) return false;
+
+ if($max && $max != -1 && trANSLATE_MEMSTRING($memoryLimit) > translate_memstring($max)) return false;
// Increase the memory limit if it's too low
if($memoryLimit == -1 || translate_memstring($memoryLimit) > translate_memstring($curLimit)) {

2 comments on commit 6ef4f9a

caffeineinc replied Nov 9, 2016 edited

trANSLATE_MEMSTRING isn't actually a function. Just commenting as a note to make a pull request. :)

Owner

kinglozzer replied Nov 9, 2016

@caffeineinc

/**
* Turn a memory string, such as 512M into an actual number of bytes.
*
* @param A memory limit string, such as "64M"
*/
function translate_memstring($memString) {
switch(strtolower(substr($memString, -1))) {
case "k": return round(substr($memString, 0, -1)*1024);
case "m": return round(substr($memString, 0, -1)*1024*1024);
case "g": return round(substr($memString, 0, -1)*1024*1024*1024);
default: return round($memString);
}
}
. Thankfully PHP is case-insensitive for function names 😉 I think the casing has been fixed now anyway

Please sign in to comment.