diff --git a/CHANGELOG.md b/CHANGELOG.md index 740fae499..e0353ebce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Better logic in `Utils::normalizePath` to handle externals properly [#2216](https://github.com/getgrav/grav/issues/2216) * Fixed to force all `Page::taxonomy` to be treated as strings [#2446](https://github.com/getgrav/grav/issues/2446) * Fixed issue with `Grav['user']` not being available [form#332](https://github.com/getgrav/grav-plugin-form/issues/332) + * Updated rounding logic for `Utils::parseSize()` [#2394](https://github.com/getgrav/grav/issues/2394) * Fixed Flex simple storage not being properly initialized if used with caching # v1.6.3 diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index e15894a2e..42f1fbe69 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -1405,10 +1405,10 @@ abstract class Utils $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); $size = preg_replace('/[^0-9\.]/', '', $size); if ($unit) { - return (int)((int)$size * (1024 ** stripos('bkmgtpezy', $unit[0]))); + return round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))); + } else { + return round($size); } - - return (int)$size; } /**