From: Tim Düsterhus Date: Thu, 3 Aug 2023 12:22:55 +0000 (+0200) Subject: Use `FileUtil::getMemoryLimit()` in SystemCheckPage X-Git-Tag: 6.0.0_Alpha_8~13^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7b86325eff74ae71b65daf3ac7bd612f95471c4f;p=GitHub%2FWoltLab%2FWCF.git Use `FileUtil::getMemoryLimit()` in SystemCheckPage --- diff --git a/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php b/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php index ab41a88ef5..cb8431abd2 100644 --- a/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/SystemCheckPage.class.php @@ -74,7 +74,7 @@ class SystemCheckPage extends AbstractPage 'zlib', ]; - public $phpMemoryLimit = 128; + public $phpMemoryLimit = 128 * 1024 * 1024; public $phpVersions = [ 'minimum' => '8.1.2', @@ -331,50 +331,17 @@ class SystemCheckPage extends AbstractPage protected function validatePhpMemoryLimit() { - $this->results['php']['memoryLimit']['required'] = $this->phpMemoryLimit . 'M'; + $this->results['php']['memoryLimit']['required'] = $this->phpMemoryLimit; - $memoryLimit = \ini_get('memory_limit'); + $memoryLimit = FileUtil::getMemoryLimit(); // Memory is not limited through PHP. if ($memoryLimit == -1) { $this->results['php']['memoryLimit']['value'] = "\u{221E}"; $this->results['php']['memoryLimit']['result'] = true; } else { - // Completely numeric, PHP assumes this to be a value in bytes. - if (\is_numeric($memoryLimit)) { - $memoryLimit = $memoryLimit / 1024 / 1024; - - $this->results['php']['memoryLimit']['value'] = $memoryLimit . 'M'; - $this->results['php']['memoryLimit']['result'] = ($memoryLimit >= $this->phpMemoryLimit); - } else { - // PHP supports the 'K', 'M' and 'G' shorthand notations. - if (\preg_match('~^(\d+)([KMG])$~', $memoryLimit, $matches)) { - switch ($matches[2]) { - case 'K': - $memoryLimit = $matches[1] / 1024; - - $this->results['php']['memoryLimit']['value'] = $memoryLimit . 'M'; - $this->results['php']['memoryLimit']['result'] = ($memoryLimit >= $this->phpMemoryLimit); - break; - - case 'M': - $this->results['php']['memoryLimit']['value'] = $memoryLimit; - $this->results['php']['memoryLimit']['result'] = ($matches[1] >= $this->phpMemoryLimit); - break; - - case 'G': - $this->results['php']['memoryLimit']['value'] = $memoryLimit; - $this->results['php']['memoryLimit']['result'] = ($matches[1] * 1024 >= $this->phpMemoryLimit); - break; - - default: - $this->results['php']['memoryLimit']['value'] = $memoryLimit; - $this->results['php']['memoryLimit']['result'] = false; - - return; - } - } - } + $this->results['php']['memoryLimit']['value'] = FileUtil::formatFilesizeBinary($memoryLimit); + $this->results['php']['memoryLimit']['result'] = ($memoryLimit >= $this->phpMemoryLimit); } $this->results['status']['php'] = $this->results['status']['php'] && $this->results['php']['memoryLimit']['result']; diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 154bbf8d12..5b51d6567c 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2801,7 +2801,7 @@ Abschnitte dürfen nicht leer sein und nur folgende Zeichen enthalten: [a-z - + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index dd9bfff307..6f957be019 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2730,7 +2730,7 @@ If you have already bought the licenses for the listed apps, th - +