Skip to content

Commit

Permalink
\ini_parse_quantity() is provided by the Symfony polyfill
Browse files Browse the repository at this point in the history
This reintroduces the changes made in 76b16ba which was reverted in 5d52de1 due to a bug in an earlier version of Symphony’s polyfill.
  • Loading branch information
dtdesign committed Jun 20, 2024
1 parent ed0ebd2 commit cc8e5f7
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions wcfsetup/install/files/lib/util/FileUtil.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,30 +521,8 @@ public static function getMemoryLimit(): int
// no limit
if ($memoryLimit == "-1") {
self::$memoryLimit = -1;
} 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;
}
}
self::$memoryLimit = \ini_parse_quantity($memoryLimit);
}
}

Expand Down

0 comments on commit cc8e5f7

Please sign in to comment.