From: Chad Horohoe Date: Tue, 4 Aug 2009 11:18:05 +0000 (+0000) Subject: Better patch for parsing PHP's memory limits from OverlordQ. X-Git-Tag: 1.31.0-rc.0~40516 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=2b0d98150076a1201111ca4217999a607404af76;p=lhc%2Fweb%2Fwiklou.git Better patch for parsing PHP's memory limits from OverlordQ. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 2dba0d0e86..9877d941e1 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3195,11 +3195,16 @@ function wfObjectToArray( $object, $recursive = true ) { /* Parse PHP's silly format for memory limits */ function wfParseMemoryLimit( $memlimit ) { - $n = intval( $memlimit ); - if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) { - $n = intval( $m[1] * (1024*1024) ); - } - return $n; + $last = strtolower($memlimit[strlen($memlimit)-1]); + $val = intval( $memlimit ); + switch($last) { + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + return $val; } /* Get the normalised IETF language tag