mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix File::ini2bytes() in PHP 7
This commit is contained in:
parent
e22cd4db00
commit
f101697f8e
@ -883,19 +883,28 @@ class File extends DataObject {
|
||||
/**
|
||||
* Convert a php.ini value (eg: 512M) to bytes
|
||||
*
|
||||
* @param string $phpIniValue
|
||||
* @param string $iniValue
|
||||
* @return int
|
||||
*/
|
||||
public static function ini2bytes($PHPiniValue) {
|
||||
switch(strtolower(substr(trim($PHPiniValue), -1))) {
|
||||
public static function ini2bytes($iniValue) {
|
||||
$iniValues = str_split(trim($iniValue));
|
||||
$unit = strtolower(array_pop($iniValues));
|
||||
$quantity = (int) implode($iniValues);
|
||||
switch ($unit) {
|
||||
case 'g':
|
||||
$PHPiniValue *= 1024;
|
||||
$quantity *= 1024;
|
||||
// deliberate no break
|
||||
case 'm':
|
||||
$PHPiniValue *= 1024;
|
||||
$quantity *= 1024;
|
||||
// deliberate no break
|
||||
case 'k':
|
||||
$PHPiniValue *= 1024;
|
||||
$quantity *= 1024;
|
||||
// deliberate no break
|
||||
default:
|
||||
// no-op: pre-existing behaviour
|
||||
break;
|
||||
}
|
||||
return $PHPiniValue;
|
||||
return $quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user