From e1c317c69747f89ce0ad2848849667e9a4c11065 Mon Sep 17 00:00:00 2001 From: cemacar Date: Mon, 16 Mar 2026 18:16:24 +0300 Subject: [PATCH] Fix wrong comparison in installation pre-checks The upload_max_filesize and post_max_size values from php.ini can use K, M, or G suffixes (e.g. 2048K, 8M). The previous code cast these values directly to int and then multiplied by 1024*1024, ignoring the unit suffix entirely. This caused incorrect comparisons like 2048K being treated as greater than 8M. Add a convertToBytes() helper that properly parses the PHP shorthand notation into bytes before comparing. Fixes #3085 --- install/index.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/install/index.php b/install/index.php index 010a9e7c3..a98b60693 100644 --- a/install/index.php +++ b/install/index.php @@ -10,6 +10,18 @@ DJ7NT - Docker Readiness - April 2024 HB9HIL - Big UX and backend upgrade - July 2024 */ require_once('includes/install_config/install_lib.php'); + +function convertToBytes(string $value): int { + $value = trim($value); + $num = (int) $value; + $unit = strtoupper(substr($value, -1)); + switch ($unit) { + case 'G': return $num * 1024 * 1024 * 1024; + case 'M': return $num * 1024 * 1024; + case 'K': return $num * 1024; + default: return $num; + } +} $http_scheme = is_https() ? "https" : "http"; $directory = ltrim(str_replace('/install', '', dirname($_SERVER['SCRIPT_NAME'])), '/'); @@ -171,7 +183,7 @@ if (!file_exists('.lock') && !file_exists('../application/config/config.php') && = ($upload_max_filesize * 1024 * 1024)) { // compare with given value in bytes ?> @@ -190,7 +202,7 @@ if (!file_exists('.lock') && !file_exists('../application/config/config.php') && = ($post_max_size * 1024 * 1024)) { // compare with given value in bytes ?>