Skip to content

Commit 36b9bde

Browse files
committed
Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
Now that we properly dereference references of the superglobals. we also need to dereference contained references to avoid to string conversion. Closes GH-7014.
1 parent 3938bfb commit 36b9bde

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.21
44

5-
5+
- Standard:
6+
. Fixed bug #81048 (phpinfo(INFO_VARIABLES) "Array to string conversion").
7+
(cmb)
68

79
03 Jun 2021, PHP 7.4.20
810

ext/standard/info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length)
202202
} else {
203203
php_info_print(" => ");
204204
}
205+
ZVAL_DEREF(tmp);
205206
if (Z_TYPE_P(tmp) == IS_ARRAY) {
206207
if (!sapi_module.phpinfo_as_text) {
207208
zend_string *str = zend_print_zval_r_to_str(tmp, 0);

ext/standard/tests/bug81048.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #81048 (phpinfo(INFO_VARIABLES) "Array to string conversion")
3+
--FILE--
4+
<?php
5+
6+
$_ENV = [];
7+
$_SERVER = ['foo' => ['bar' => ['baz' => 'qux']]];
8+
9+
array_walk_recursive($_SERVER, function($value, $key) {
10+
// NOP
11+
});
12+
13+
phpinfo(INFO_VARIABLES);
14+
?>
15+
--EXPECT--
16+
phpinfo()
17+
18+
PHP Variables
19+
20+
Variable => Value
21+
$_SERVER['foo'] => Array
22+
(
23+
[bar] => Array
24+
(
25+
[baz] => qux
26+
)
27+
28+
)

0 commit comments

Comments
 (0)