Skip to content

Commit ce0c5b2

Browse files
committed
[RFC]Implement case-insensitive extension names in ini_get_all()
1 parent 6fe61c8 commit ce0c5b2

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎NEWS‎

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

171171
- Standard:
172+
. Made extension names in ini_get_all() case-insensitive. (Weilin Du)
172173
. Fixed bug GH-25387 (Uploaded files leak in request_parse_body()).
173174
(Kévin Dunglas)
174175
. 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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
/* Extensions without INI settings still return an empty array. */
12+
var_dump(ini_get_all('REFLECTION'));
13+
var_dump(ini_get_all('Reflection', false));
14+
15+
/* Unknown extensions still warn using the original name and return false. */
16+
var_dump(ini_get_all('NoSuchExtension'));
17+
var_dump(ini_get_all('NoSuchExtension', false));
18+
?>
19+
--EXPECTF--
20+
bool(true)
21+
bool(true)
22+
bool(true)
23+
bool(true)
24+
bool(true)
25+
bool(true)
26+
bool(true)
27+
bool(true)
28+
bool(true)
29+
array(0) {
30+
}
31+
array(0) {
32+
}
33+
34+
Warning: ini_get_all(): Extension "NoSuchExtension" cannot be found in %s on line %d
35+
bool(false)
36+
37+
Warning: ini_get_all(): Extension "NoSuchExtension" cannot be found in %s on line %d
38+
bool(false)

0 commit comments

Comments
 (0)