`\ini_parse_quantity()` is provided by the Symfony polyfill
authorAlexander Ebert <ebert@woltlab.com>
Thu, 20 Jun 2024 10:50:25 +0000 (12:50 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 20 Jun 2024 10:50:25 +0000 (12:50 +0200)
This reintroduces the changes made in 76b16ba4e89a7ff46cc2e1f79a158afc1c5e4c40 which was reverted in 5d52de11b680078012eba04ae983058e6086b7d7 due to a bug in an earlier version of Symphony’s polyfill.

wcfsetup/install/files/lib/util/FileUtil.class.php

index e7a86de3e55f311adb911bbac94069c015832435..052e65f26525ff1eba1d6e84b1aa91278e3256e8 100644 (file)
@@ -521,30 +521,8 @@ final class FileUtil
             // 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);
             }
         }