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>
This commit is contained in:
Rowan Tommins 2021-03-29 19:55:57 +01:00 committed by Christoph M. Becker
parent 75cb678206
commit 206fd35a98
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
3 changed files with 25 additions and 1 deletions

4
NEWS
View File

@ -24,6 +24,10 @@ PHP NEWS
. Fixed bug #69668 (SOAP special XML characters in namespace URIs not
encoded). (cmb)
- Standard:
. Fixed bug #80915 (Taking a reference to $_SERVER hides its values from
phpinfo()). (Rowan Tommins)
01 Apr 2021, PHP 7.4.17
- Core:

View File

@ -176,7 +176,7 @@ static ZEND_COLD void php_print_gpcse_array(char *name, uint32_t name_length)
key = zend_string_init(name, name_length, 0);
zend_is_auto_global(key);
if ((data = zend_hash_find(&EG(symbol_table), key)) != NULL && (Z_TYPE_P(data) == IS_ARRAY)) {
if ((data = zend_hash_find_deref(&EG(symbol_table), key)) != NULL && (Z_TYPE_P(data) == IS_ARRAY)) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(data), num_key, string_key, tmp) {
if (!sapi_module.phpinfo_as_text) {
php_info_print("<tr>");

View File

@ -0,0 +1,20 @@
--TEST--
Bug #80915: Taking a reference to $_SERVER hides its values from phpinfo()
--FILE--
<?php
$_ENV = [];
$_SERVER = [ 'test' => 'test' ];
$reference =& $_SERVER;
phpinfo(INFO_VARIABLES);
?>
--EXPECT--
phpinfo()
PHP Variables
Variable => Value
$_SERVER['test'] => test