Skip to content

Commit

Permalink
Revert "Remove check for ini_parse_quantity"
Browse files Browse the repository at this point in the history
see symfony/polyfill#442

This reverts commit 76b16ba.
  • Loading branch information
TimWolla committed Aug 28, 2023
1 parent 1cdc3da commit 5d52de1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion wcfsetup/install/files/lib/util/FileUtil.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,30 @@ public static function getMemoryLimit(): int
// no limit
if ($memoryLimit == "-1") {
self::$memoryLimit = -1;
} else {
} 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;

case 'M':
self::$memoryLimit = $matches[1] * 1024 * 1024;
break;

case 'G':
self::$memoryLimit = $matches[1] * 1024 * 1024 * 1024;
break;
}
}
}
}

Expand Down

0 comments on commit 5d52de1

Please sign in to comment.