mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 21:29:23 +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
|
* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user