Fix File::ini2bytes() in PHP 7

This commit is contained in:
Loz Calver 2017-04-04 10:02:21 +01:00 committed by Sam Minnee
parent e22cd4db00
commit f101697f8e

View File

@ -883,19 +883,28 @@ class File extends DataObject {
/** /**
* Convert a php.ini value (eg: 512M) to bytes * Convert a php.ini value (eg: 512M) to bytes
* *
* @param string $phpIniValue * @param string $iniValue
* @return int * @return int
*/ */
public static function ini2bytes($PHPiniValue) { public static function ini2bytes($iniValue) {
switch(strtolower(substr(trim($PHPiniValue), -1))) { $iniValues = str_split(trim($iniValue));
$unit = strtolower(array_pop($iniValues));
$quantity = (int) implode($iniValues);
switch ($unit) {
case 'g': case 'g':
$PHPiniValue *= 1024; $quantity *= 1024;
// deliberate no break
case 'm': case 'm':
$PHPiniValue *= 1024; $quantity *= 1024;
// deliberate no break
case 'k': case 'k':
$PHPiniValue *= 1024; $quantity *= 1024;
// deliberate no break
default:
// no-op: pre-existing behaviour
break;
} }
return $PHPiniValue; return $quantity;
} }
/** /**