diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index 5e7293d66a6..0d4cc2f8172 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -514,29 +514,31 @@ public static function getMemoryLimit(): int $memoryLimit = \ini_get('memory_limit'); // no limit - if ($memoryLimit == -1) { + if ($memoryLimit == "-1") { self::$memoryLimit = -1; - } - - // completely numeric, PHP assumes byte - if (\is_numeric($memoryLimit)) { - self::$memoryLimit = $memoryLimit; - } + } else if (\function_exists('ini_parse_quantity')) { + self::$memoryLimit = \ini_parse_quantity($memoryLimit); + } else { + // completely numeric, PHP assumes byte + if (\is_numeric($memoryLimit)) { + self::$memoryLimit = $memoryLimit; + } - // PHP supports 'K', 'M' and 'G' shorthand notation - if (\preg_match('~^(\d+)\s*([KMG])$~i', $memoryLimit, $matches)) { - switch (\strtoupper($matches[2])) { - case 'K': - self::$memoryLimit = $matches[1] * 1024; - break; + // PHP supports 'K', 'M' and 'G' shorthand notation + if (\preg_match('~^(\d+)\s*([KMG])$~i', $memoryLimit, $matches)) { + switch (\strtoupper($matches[2])) { + case 'K': + self::$memoryLimit = $matches[1] * 1024; + break; - case 'M': - self::$memoryLimit = $matches[1] * 1024 * 1024; - break; + case 'M': + self::$memoryLimit = $matches[1] * 1024 * 1024; + break; - case 'G': - self::$memoryLimit = $matches[1] * 1024 * 1024 * 1024; - break; + case 'G': + self::$memoryLimit = $matches[1] * 1024 * 1024 * 1024; + break; + } } } }