Skip to content

Commit 46da0fd

Browse files
authored
[RFC] Implement case-insensitive extension names in ini_get_all() (#25448)
This implement RFC: https://wiki.php.net/rfc/case_insensitive_ini_get_all
1 parent 90628d5 commit 46da0fd

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎NEWS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ PHP NEWS
171171
rmdir(), touch(), chmod() or stat(). (Ilia Alshanetsky)
172172

173173
- Standard:
174+
. Made extension names in ini_get_all() case-insensitive. (Weilin Du)
174175
. Fixed bug GH-25387 (Uploaded files leak in request_parse_body()).
175176
(Kévin Dunglas)
176177
. Fixed quoted_printable_decode() truncating input at NUL bytes. (Weilin Du)

‎UPGRADING‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ PHP 8.7 UPGRADE NOTES
6060
application terminate one attribute and append further ones.
6161

6262
- Standard:
63+
. ini_get_all() now matches extension names case-insensitively using ASCII
64+
rules, independently of the current locale. Names that differ only in
65+
capitalization from a loaded extension now succeed instead of emitting a
66+
warning and returning false.
67+
RFC: https://wiki.php.net/rfc/case_insensitive_ini_get_all
6368
. bindec(), octdec(), hexdec() and base_convert() now throw an Exception
6469
when the passed string contains characters that are invalid for the
6570
specified number base.

‎ext/standard/basic_functions.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ PHP_FUNCTION(ini_get_all)
19501950
zend_ini_sort_entries();
19511951

19521952
if (extname) {
1953-
if ((module = zend_hash_find_ptr(&module_registry, extname)) == NULL) {
1953+
if ((module = zend_hash_find_ptr_lc(&module_registry, extname)) == NULL) {
19541954
php_error_docref(NULL, E_WARNING, "Extension \"%pS\" cannot be found", extname);
19551955
RETURN_FALSE;
19561956
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
ini_get_all() accepts case-insensitive extension names
3+
--FILE--
4+
<?php
5+
foreach (['PCRE', 'Pcre', 'pCrE'] as $extension) {
6+
var_dump(ini_get_all($extension) === ini_get_all('pcre'));
7+
var_dump(ini_get_all($extension, true) === ini_get_all('pcre', true));
8+
var_dump(ini_get_all($extension, false) === ini_get_all('pcre', false));
9+
}
10+
11+
var_dump(ini_get_all('REFLECTION'));
12+
var_dump(ini_get_all('Reflection', false));
13+
14+
var_dump(ini_get_all('NoSuchExtension'));
15+
var_dump(ini_get_all('NoSuchExtension', false));
16+
?>
17+
--EXPECTF--
18+
bool(true)
19+
bool(true)
20+
bool(true)
21+
bool(true)
22+
bool(true)
23+
bool(true)
24+
bool(true)
25+
bool(true)
26+
bool(true)
27+
array(0) {
28+
}
29+
array(0) {
30+
}
31+
32+
Warning: ini_get_all(): Extension "NoSuchExtension" cannot be found in %s on line %d
33+
bool(false)
34+
35+
Warning: ini_get_all(): Extension "NoSuchExtension" cannot be found in %s on line %d
36+
bool(false)

0 commit comments

Comments
 (0)