From c9c59b3f0324838b858a8a66ee5f81f7d69e6a32 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 10 Oct 2017 14:52:15 +0200 Subject: [PATCH] MemoryLimit: rewrite for PHP 7.1+ fixes #1222 --- library/Director/Application/MemoryLimit.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/library/Director/Application/MemoryLimit.php b/library/Director/Application/MemoryLimit.php index 54460a03..beb04609 100644 --- a/library/Director/Application/MemoryLimit.php +++ b/library/Director/Application/MemoryLimit.php @@ -33,17 +33,19 @@ class MemoryLimit public static function parsePhpIniByteString($string) { $val = trim($string); - $last = strtoupper(substr($val, -1, 1)); - switch ($last) { - case 'G': - $val *= 1024; + if (preg_match('/^(\d+)([KMG])$/', $val, $m)) { + $val = $m[1]; + switch ($m[2]) { + case 'G': + $val *= 1024; // Intentional fall-through - case 'M': - $val *= 1024; + case 'M': + $val *= 1024; // Intentional fall-through - case 'K': - $val *= 1024; + case 'K': + $val *= 1024; + } } return intval($val);