Skip to content

Commit 206fd35

Browse files
IMSoPcmb69
authored andcommitted
Handle reference zvals when outputting superglobals in phpinfo()
Fixes <https://bugs.php.net/80915>. Closes GH-80915. Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
1 parent 75cb678 commit 206fd35

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ PHP NEWS
2424
. Fixed bug #69668 (SOAP special XML characters in namespace URIs not
2525
encoded). (cmb)
2626

27+
- Standard:
28+
. Fixed bug #80915 (Taking a reference to $_SERVER hides its values from
29+
phpinfo()). (Rowan Tommins)
30+
2731
01 Apr 2021, PHP 7.4.17
2832

2933
- Core:

ext/standard/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length)
176176
key = zend_string_init(name, name_length, 0);
177177
zend_is_auto_global(key);
178178

179-
if ((data = zend_hash_find(&EG(symbol_table), key)) != NULL && (Z_TYPE_P(data) == IS_ARRAY)) {
179+
if ((data = zend_hash_find_deref(&EG(symbol_table), key)) != NULL && (Z_TYPE_P(data) == IS_ARRAY)) {
180180
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(data), num_key, string_key, tmp) {
181181
if (!sapi_module.phpinfo_as_text) {
182182
php_info_print("<tr>");

ext/standard/tests/bug80915.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #80915: Taking a reference to $_SERVER hides its values from phpinfo()
3+
--FILE--
4+
<?php
5+
6+
$_ENV = [];
7+
$_SERVER = [ 'test' => 'test' ];
8+
9+
$reference =& $_SERVER;
10+
11+
phpinfo(INFO_VARIABLES);
12+
13+
?>
14+
--EXPECT--
15+
phpinfo()
16+
17+
PHP Variables
18+
19+
Variable => Value
20+
$_SERVER['test'] => test

0 commit comments

Comments
 (0)