From ce0c5b251d66cd72e0177ea9438ea5ad4ef10ac5 Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Sat, 14 Nov 2026 01:40:59 +0800 Subject: [PATCH 1/2] [RFC]Implement case-insensitive extension names in ini_get_all() --- NEWS | 1 + UPGRADING | 5 +++ ext/standard/basic_functions.c | 2 +- .../ini_get_all_case_insensitive.phpt | 38 +++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt diff --git a/NEWS b/NEWS index 4938b79b0713..048976ba346a 100644 --- a/NEWS +++ b/NEWS @@ -169,6 +169,7 @@ PHP NEWS rmdir(), touch(), chmod() or stat(). (Ilia Alshanetsky) - Standard: + . Made extension names in ini_get_all() case-insensitive. (Weilin Du) . Fixed bug GH-25387 (Uploaded files leak in request_parse_body()). (Kévin Dunglas) . Fixed quoted_printable_decode() truncating input at NUL bytes. (Weilin Du) diff --git a/UPGRADING b/UPGRADING index d9242ecb3c17..4f9c01765908 100644 --- a/UPGRADING +++ b/UPGRADING @@ -60,6 +60,11 @@ PHP 8.7 UPGRADE NOTES application terminate one attribute and append further ones. - Standard: + . ini_get_all() now matches extension names case-insensitively using ASCII + rules, independently of the current locale. Names that differ only in + capitalization from a loaded extension now succeed instead of emitting a + warning and returning false. + RFC: https://wiki.php.net/rfc/case_insensitive_ini_get_all . bindec(), octdec(), hexdec() and base_convert() now throw an Exception when the passed string contains characters that are invalid for the specified number base. diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index db302ab724ab..9ae99b6f1eed 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1950,7 +1950,7 @@ PHP_FUNCTION(ini_get_all) zend_ini_sort_entries(); if (extname) { - if ((module = zend_hash_find_ptr(&module_registry, extname)) == NULL) { + if ((module = zend_hash_find_ptr_lc(&module_registry, extname)) == NULL) { php_error_docref(NULL, E_WARNING, "Extension \"%pS\" cannot be found", extname); RETURN_FALSE; } diff --git a/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt b/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt new file mode 100644 index 000000000000..9ce48f46e4b3 --- /dev/null +++ b/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt @@ -0,0 +1,38 @@ +--TEST-- +ini_get_all() accepts case-insensitive extension names +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +array(0) { +} +array(0) { +} + +Warning: ini_get_all(): Extension "NoSuchExtension" cannot be found in %s on line %d +bool(false) + +Warning: ini_get_all(): Extension "NoSuchExtension" cannot be found in %s on line %d +bool(false) From 65081fb6fc5b461cb8abdfbaa855b314aaf016f4 Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Sat, 14 Nov 2026 02:30:42 +0800 Subject: [PATCH 2/2] [skip ci] feedback --- .../tests/general_functions/ini_get_all_case_insensitive.phpt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt b/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt index 9ce48f46e4b3..fe1cd3350e17 100644 --- a/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt +++ b/ext/standard/tests/general_functions/ini_get_all_case_insensitive.phpt @@ -8,11 +8,9 @@ foreach (['PCRE', 'Pcre', 'pCrE'] as $extension) { var_dump(ini_get_all($extension, false) === ini_get_all('pcre', false)); } -/* Extensions without INI settings still return an empty array. */ var_dump(ini_get_all('REFLECTION')); var_dump(ini_get_all('Reflection', false)); -/* Unknown extensions still warn using the original name and return false. */ var_dump(ini_get_all('NoSuchExtension')); var_dump(ini_get_all('NoSuchExtension', false)); ?>