Bug #80915 [Com]: Taking a reference to $_SERVER hides it's values from phpinfo()
Edit report at https://bugs.php.net/bug.php?id=80915&edit=1
ID: 80915
Comment by: rowan dot collins at gmail dot com
Reported by: donatj at gmail dot com
Summary: Taking a reference to $_SERVER hides it's values
from phpinfo()
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: All
PHP Version: 8.0.3
Block user comment: N
Private report: N
New Comment:
Simpler reproduction case:
php -r '$foo =& $_SERVER; phpinfo(INFO_VARIABLES);'
This works as expected on 5.6, but fails on 7.0 - which makes sense, as the implementation of
references was heavily changed in that version.
Previous Comments:
------------------------------------------------------------------------
[2021-03-29 17:50:31] donatj at gmail dot com
It's not an entirely pointless use of references, just mostly.
If $_SERVER should change after declaring an instance from globals you might want to inherit those
changes
------------------------------------------------------------------------
[2021-03-29 17:40:02] ecegefef dot wfwfwg at fff dot gg
clap on the fingers for pointless use of references and than even for special handled magic vars
------------------------------------------------------------------------
[2021-03-29 17:25:48] donatj at gmail dot com
Description:
------------
$_SERVER disappeared from our admin phpinfo page, after a bit of poking I figured
out a middleware we're using takes a reference to $_SERVER.
It only reads, doesn't write to it at all - but it breaks phpinfo.
This can be seen in my given example code where simply:
$foo =& $_SERVER;
breaks phpinfo's variable output
Test script:
---------------
<?php
echo "---- Expected Output ----\n\n";
\phpinfo(INFO_VARIABLES);
echo "\n\n---- Actual Broken Output ----\n\n";
$foo =& $_SERVER;
\phpinfo(INFO_VARIABLES);
echo "\n\n---- Proof that \$_SERVER isn't broken ----\n\n";
print_r($_SERVER);
Expected result:
----------------
(truncated to relevant output)
phpinfo()
PHP Variables
Variable => Value
$_SERVER['TMPDIR'] => /var/folders/dr/cpm01_51333c1px2yzc8qr9xq1kth0/T/
$_SERVER['__CF_USER_TEXT_ENCODING'] => 0x6E196A00:0x0:0x0
$_SERVER['HOME'] => /Users/jdonat
$_SERVER['SHELL'] => /bin/zsh
$_SERVER['Apple_PubSub_Socket_Render'] =>
/private/tmp/com.apple.launchd.d1nNRxAouL/Render
$_SERVER['SSH_AUTH_SOCK'] => /private/tmp/com.apple.launchd.7DMDsXS1qP/Listeners
$_SERVER['PATH'] => /usr/bin:/bin:/usr/sbin:/sbin
$_SERVER['LOGNAME'] => jdonat
$_SERVER['DISPLAY'] =>
/private/tmp/com.apple.launchd.DHo7IG8khp/org.macosforge.xquartz:0
$_SERVER['XPC_SERVICE_NAME'] => com.electron.standard-otter.146872
$_SERVER['USER'] => jdonat
$_SERVER['XPC_FLAGS'] => 0x0
$_SERVER['PHP_SELF'] => -
$_SERVER['SCRIPT_NAME'] => -
$_SERVER['SCRIPT_FILENAME'] =>
$_SERVER['PATH_TRANSLATED'] =>
$_SERVER['DOCUMENT_ROOT'] =>
$_SERVER['REQUEST_TIME_FLOAT'] => 1617038447.9799
$_SERVER['REQUEST_TIME'] => 1617038447
$_SERVER['argv'] => Array
(
[0] => -
)
$_SERVER['argc'] => 1
Actual result:
--------------
(truncated to relevant output)
phpinfo()
PHP Variables
Variable => Value
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80915&edit=1
Thread (6 messages)