From e6ef70c97b9dc5f3f3fb8bd4b7460df1291f84cb Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 19 Apr 2024 07:49:28 +0900 Subject: [PATCH 1/2] fix: [ErrorException] Undefined array key If a setting does not exists, ini_get_all() does not have the key. --- system/Security/CheckPhpIni.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Security/CheckPhpIni.php b/system/Security/CheckPhpIni.php index 6bbd8619c090..633c087080cf 100644 --- a/system/Security/CheckPhpIni.php +++ b/system/Security/CheckPhpIni.php @@ -142,8 +142,8 @@ public static function checkIni(): array foreach ($items as $key => $values) { $output[$key] = [ - 'global' => $ini[$key]['global_value'], - 'current' => $ini[$key]['local_value'], + 'global' => array_key_exists($key, $ini) ? $ini[$key]['global_value'] : 'disabled', + 'current' => array_key_exists($key, $ini) ? $ini[$key]['local_value'] : 'disabled', 'recommended' => $values['recommended'] ?? '', 'remark' => $values['remark'] ?? '', ]; From 8d5143380a4e6bd6995dcf425b0a49592802c8b4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 19 Apr 2024 17:01:23 +0900 Subject: [PATCH 2/2] refactor: don't call array_key_exists() twice --- system/Security/CheckPhpIni.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/Security/CheckPhpIni.php b/system/Security/CheckPhpIni.php index 633c087080cf..4cef565ad7d6 100644 --- a/system/Security/CheckPhpIni.php +++ b/system/Security/CheckPhpIni.php @@ -141,9 +141,10 @@ public static function checkIni(): array $ini = ini_get_all(); foreach ($items as $key => $values) { + $hasKeyInIni = array_key_exists($key, $ini); $output[$key] = [ - 'global' => array_key_exists($key, $ini) ? $ini[$key]['global_value'] : 'disabled', - 'current' => array_key_exists($key, $ini) ? $ini[$key]['local_value'] : 'disabled', + 'global' => $hasKeyInIni ? $ini[$key]['global_value'] : 'disabled', + 'current' => $hasKeyInIni ? $ini[$key]['local_value'] : 'disabled', 'recommended' => $values['recommended'] ?? '', 'remark' => $values['remark'] ?? '', ];