php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29176 $GLOBALS['_REQUEST'], $GLOBALS['_ENV'] AND $GLOBALS['_SERVER'] are empty
Submitted: 2004-07-15 04:27 UTC Modified: 2004-11-12 08:46 UTC
Votes:30
Avg. Score:4.5 ± 0.8
Reproduced:22 of 25 (88.0%)
Same Version:12 (54.5%)
Same OS:9 (40.9%)
From: webmaster at ragnarokonline dot de Assigned: sesser (profile)
Status: Wont fix Package: Variables related
PHP Version: 5.0.0 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: webmaster at ragnarokonline dot de
New email:
PHP Version: OS:

 

 [2004-07-15 04:27 UTC] webmaster at ragnarokonline dot de
Description:
------------
$_GLOBALS somehow doesn't contain the arrays $_REQUEST, 
$_ENV and $_SERVER. This worked fine in PHP4. 

Reproduce code:
---------------
<?php

var_dump($GLOBALS['_SERVER']);
var_dump($GLOBALS['_ENV']);
var_dump($GLOBALS['_REQUEST']);

?>

Expected result:
----------------
The contents of the arrays $_SERVER, $_ENV and $_REQUEST 
are being printed. 

Actual result:
--------------
NULL NULL NULL is being printed. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-15 12:23 UTC] webmaster at ragnarokonline dot de
Someone at Turck-MMCache found out in a related bug I've reported, that a workaround is to set
register_long_arrays = On
in the php.ini
 [2004-07-15 15:21 UTC] webmaster at ragnarokonline dot de
AFAICS the php-commandline is not affected to this bug.
 [2004-07-16 02:22 UTC] tmgh at www dot deyang dot gov dot cn
yes,it's me to post the bug for turck-mmcache.and when set register_long_arrays = On in the php.ini,php5 works fine with turck-mmcache.i dont' know whether it's php5's bug or mmcache's bug.maybe someone can fix it.
but without mmcache and set register_long_arrays = Off in the php.ini,php5 works fine.maybe it's mmcache's bug,i think.
 [2004-07-16 02:26 UTC] webmaster at ragnarokonline dot de
I have tested this with the MMCache section commented out. But I'll recheck later, if I'm on my SuSE Box again.
 [2004-07-16 02:41 UTC] tmgh at www dot deyang dot gov dot cn
if you fix the bug,please email to me and i want to use php5 and mmcache.thanks.
 [2004-07-16 02:53 UTC] webmaster at ragnarokonline dot de
I have tested this now. The MMCache-Section was commented out, so its definately not related.

PS: If a dev fixes this, this is checked into CVS, so you can simply compile or download the latest snapshot after the fix have been checked in.

Regards,
  Christian Stadler
 [2004-07-16 03:04 UTC] tmgh at www dot deyang dot gov dot cn
at present,the cvs does not have newest source.maybe i have to wait for few time.thanks for your response.
ps:it's mmcache's bug?
 [2004-07-16 03:09 UTC] webmaster at ragnarokonline dot de
The dev replys, when he checked in a fix. So we have to wait, what the devs say ;)
 [2004-07-16 09:35 UTC] tmgh at www dot deyang dot gov dot cn
if set
register_long_arrays=Off
auto_globals_jit=off
,php5+mmcache2.4.7-cvs work greatly.
can somebody tell me what's auto_globals_jit?
 [2004-08-19 09:20 UTC] info at webaq dot com
PHP File use "SafeGuard Suite 3.5.0" encode 
Apache 1.3.29
PHP 5.0.0
Zend Engine v2.0.0
Zend Optimizer v2.5.3

Notice: Undefined variable: _SERVER in /www/ZendEncode.php on line 2

Undefined variable: _SERVER!!! >_<
 [2004-08-19 23:01 UTC] marcus at synchromedia dot co dot uk
I'm seeing this in a fresh compile of 5.0.1 on RedHat EL 
3. Again, turning register_long_arrays is a workaround 
until it's fixed properly. FWIW, I'm also using mmcache.
 [2004-08-20 19:56 UTC] webmaster at ragnarokonline dot de
Perhaps triggering the jit, when $GLOBALS['_REQUEST'], $GLOBALS['_ENV'] or $GLOBALS['_SERVER'] is being called should fix the issue?
 [2004-08-20 20:09 UTC] webmaster at ragnarokonline dot de
mmh ... or even $GLOBALS in general, so var_dump($GLOBALS) would include $_SERVER, $_ENV and $_REQUEST and scripts, like

<?php

var_dump(in_array('_SERVER', array_keys($GLOBALS)));

?>

work as expected, which means the above script would return bool(true) for example?
 [2004-08-24 03:12 UTC] webmaster at ragnarokonline dot de
Changing OS from SuSE 9.0 to All, since this is not limited to SuSE.
 [2004-11-11 09:17 UTC] marrtins at hackers dot lv
i think this is a mmcache issue. today i get similar problems - once file is loaded with mmcache it is ok, next time there is no more $_SERVER variable executing that script again.

notice, that it happens with apache (v 1.3.33), from command line same script works well (php5.0.2).

also, with php4.3.7+apache1.3.27 it works as excpected too.
 [2004-11-11 09:56 UTC] tony2001@php.net
Can you reproduce it without mmcache enabled ?
 [2004-11-11 10:58 UTC] webmaster at ragnarokonline dot de
Yes, I could reproduce this without using mmcache.

This is dependent of auto_globals_jit. The problem is, that for example var_dump($_SERVER); does trigger the jit, but that var_dump($GLOBALS['_SERVER']); doesn't.
 [2004-11-12 08:46 UTC] derick@php.net
$GLOBALS["_SERVER"] would be silly to use anyway. I am going to mark this as Wont Fix as this is not guaranteed to work.
 [2010-06-05 12:47 UTC] php at caves dot org dot uk
An alternative to the workaround of putting "register_long_arrays = On", in php.ini is to include a reference to $_SERVER (etc) *anywhere* in your PHP script. This seems to trigger the population of $GLOBALS with the correct data. The following example demonstrates this. Un-comment the lines at the bottom to implement and demonstrate the work-around.

echo "_SERVER  array is {$GLOBALS['_SERVER']}  <BR>";
echo "_GET     array is {$GLOBALS['_GET']}     <BR>";
echo "_POST    array is {$GLOBALS['_POST']}    <BR>";
echo "_FILES   array is {$GLOBALS['_FILES']}   <BR>";
echo "_COOKIE  array is {$GLOBALS['_COOKIE']}  <BR>";
echo "_REQUEST array is {$GLOBALS['_REQUEST']} <BR>";
echo "_ENV     array is {$GLOBALS['_ENV']}     <BR><BR>";
//echo "\$_SERVER    is $_SERVER<BR>";
//echo "\$_REQUEST   is $_REQUEST<BR>";
//echo "\$_ENV       is $_ENV<BR>";
 [2010-06-06 21:35 UTC] php at caves dot org dot uk
Oh, I am an idiot. Its not strange behaviour at all, is it?  Its a perfectly understandable side-effect of having auto_globals_jit = on, and instead of setting that to off, its better not to use the superglobal $GLOBALS for accessing _SERVER.  I should have read the discussion properly!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Mar 11 19:01:31 2025 UTC