php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27375 $DOCUMENT_ROOT sometimes empty when register_globals=on
Submitted: 2004-02-24 07:30 UTC Modified: 2004-02-25 06:17 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: oliver at update dot ch Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 4.3.3. OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oliver at update dot ch
New email:
PHP Version: OS:

 

 [2004-02-24 07:30 UTC] oliver at update dot ch
Description:
------------
The Global Variable $GLOBALS["DOCUMENT_ROOT"] or $DOCUMENT_ROOT is sometimes empty.
After a reload $DOCUMENT_ROOT mostly contains the expected value.
see also http://bugs.php.net/bug.php?id=25172


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-24 12:03 UTC] sniper@php.net
When this happens, is register_globals on or off? 
Do you override it in some vhost ?
How do you do it? 

In other words: Not enough information..

 [2004-02-24 12:59 UTC] oliver at update dot ch
register_globals is always set on. register_globals is 
set to on in the php.ini file.

SERVER_SOFTWARE:
Apache/2.0.47 (Unix) mod_perl/1.99_09 Perl/v5.6.1 
mod_ssl/2.0.47 OpenSSL/0.9.6c DAV/2 FrontPain/5.0.0.0
 [2004-02-24 16:57 UTC] sniper@php.net
Second try. (If I have to ask these same things for the 3rd time, this bug report will vanish mysteriously..)

1. How did you configure Apache? (configure line used)
2. What MPM are you using with Apache?
3. What is register_globals set to WHEN this happens?
(put var_dump(ini_get("register_globals")); in the beginning of your script, see bug #24253 what a nice short test script looks like)
4. Are you sure there aren't any .htaccess files or vhosts setting register_globals to something else? Or setting any other php.ini options? (using php_value, php_admin_value, php_flag or php_admin_flag directives)
5. How was PHP configured into Apache? (as module or CGI binary??)

 [2004-02-25 02:04 UTC] oliver at update dot ch
Sorry about that. I'm not the pro on stuff like this. 
But I try again:

Configuration:
--------------
'./configure' '--with-apxs2=/opt/httpd-2.0.47/bin/apxs' 
'--with-config-file-path=/etc/httpd2' '--prefix=/opt/
php-4.x' '--enable-versioning' '--with-gd' '--with-jpeg-
dir=/usr' '--with-xpm-dir=/usr' '--with-bz2' '--with-
freetype-dir=/usr' '--enable-gd-native-ttf' '--enable-
debug=no' '--with-exec-dir=/opt/php-4.x/run' '--enable-
track-vars=yes' '--disable-cgi' '--enable-calendar' '--
with-ttf' '--with-imap' '--with-ft' '--with-xml' '--
with-mhash' '--with-mcrypt' '--with-bcmath' '--with-
snmp' '--enable-ucd-snmp-hack' '--enable-ucd-snmp-
compatibility' '--with-pdflib=/opt/pdflib-4.0' '--with-
zlib' '--enable-trans-sid' '--with-openssl' '--with-
wddx' '--with-crack' '--with-kerberos' '--with-gettext'

Reproduce code:
---------------
register_globals: "<?=ini_get('register_globals')?>"
$GLOBALS["DOCUMENT_ROOT"] = "<?
=$GLOBALS["DOCUMENT_ROOT"];?>
$DOCUMENT_ROOT: "<?=$DOCUMENT_ROOT?>"
$_SERVER["DOCUMENT_ROOT"]: "<?=$_SERVER[ 'DOCUMENT_ROOT' 
]?>"

Expected result:
----------------
register_globals: "1"
$GLOBALS["DOCUMENT_ROOT"] = "/home/www/
$DOCUMENT_ROOT: "/home/www/"
$_SERVER["DOCUMENT_ROOT"]: "/home/www/"

Result (tested on 02/24/04):
--------------
register_globals: "1"
$GLOBALS["DOCUMENT_ROOT"] = ""
$DOCUMENT_ROOT: ""
$_SERVER["DOCUMENT_ROOT"]: "/home/www/"

PHP-Version is 4.3.3.

The thing is, that I couldn't reproduce the result today 
(02/25). So I guess, you can really let vanish this 
report. Thanks for the help anyway.
 [2004-02-25 06:17 UTC] sniper@php.net
If you had bothered searching the bug database first you would have find couple of dozen similar reports. And also that this is most likely FIXED in CVS. (get stable snapshot from http://snaps.php.net/ )

 [2004-03-07 03:22 UTC] rob at realmsolutions dot com
OK, I've got similar but even weirder problem.  I just installed the latest production releases of apache2/php and now I occasionally get _wrong_ values in the DOCUMENT_ROOT variable.  Instead of containing the pathname of the current virtual host, it sometimes contains the pathname of a different virtual host also configured on this server!
There is definitely some problem here, if I click from vhost site to vhost site, I can get these errors repeatedly.  Since I'm including files based on the DOCUMENT_ROOT, it manifests itself as an error that looks like this:

Warning:
main(/home/wrongwebsite/www/includes/functions_generic.php): failed to open stream: No such file or directory in /home/correctwebsite/www/includes/config.php on line 47

In this example its _should_ be including the file functions_generic from "correctwebsite", not "wrongwebsite"

After the first instance of this error, it seems to go away until I switch to another website, where it may or may not happen again...                                                  
                         
FYI, here are the flags set in my virtualhost:
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_flag register_globals off
php_admin_flag display_errors on
 [2004-03-07 04:36 UTC] rob at realmsolutions dot com
OK, this was not fixed by the latest snapshot, which I just tried, and still get the same results...  Please reopen this bug, its not bogus.

Here's more info, let me know if you need anything else.
I've installed apache 2.0.48 with the latest php 4.3.4 snapshot. I always have register globals off in both php.ini and defined that way in the vhost too.  I always refer to the variable as $_SERVER["DOCUMENT_ROOT"].

I have about 80 virtualhosts set up, and I've had a wide variety of them have the DOCUMENT_ROOT var get the wrong pathname. But the weird thing is that when the pathname is wrong, its always the same path from another vhost.  The wierd thing is, that particular vhost doesnt really stand out in any obvious way... its not the first vhost in the config, its not the last either... kinda in the middle. its not alphabetically first or last, its not the site that gets the most traffic, nor the least.  The only thing unusual about it is that it has alot of complex mod_rewriting going on, however, its not the only vhost that uses complex mod_rewriting either.... so I'm kinda stumped as to why it always seems to have the _same_wrong_path_ in the DOCUMENT_ROOT variable!  

If you want or need any more info, please just ask or tell me what to do!
 [2004-03-07 14:05 UTC] rob at realmsolutions dot com
ACK.  When I compiled/installed the latest snapshot last night, it didnt install the module for some reason... So I did a clean config/make/make install and this time it did install properly.  Now it appears that the problem may be fixed.. After several minutes of trying to reproduce the error, I'm unable to, so as of now, I am thinking this bug is fixed.
 [2013-03-18 10:38 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329807
Log: translate lcfirst.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-18 10:41 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329808
Log: translate
setup.xml
reference.xml
constants.xml
book.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-18 10:52 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329809
Log: translate levenshtein.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-18 10:55 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329810
Log: translate ltrim.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-18 15:13 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329812
Log: aliases.xml
book.xml
configure.xml
cubridmysql.xml
examples.xml
reference.xml
setup.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-18 15:30 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329813
Log: translate htmlspecialchars_decode
--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-19 15:44 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329834
Log: translate pdo/commit.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-20 04:34 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329836
Log: translate pdo/rollback.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-20 04:36 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329837
Log: translate pdo

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-20 14:46 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329839
Log: translate pdo/getavailabledrivers.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-20 14:46 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329840
Log: translate pdo/intransaction.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-20 14:47 UTC] daijie@php.net
Automatic comment from SVN on behalf of daijie
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329841
Log: translate pdo/lastinsertid.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-24 16:03 UTC] ichenshy@php.net
Automatic comment from SVN on behalf of ichenshy
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329903
Log: translate pdo/lastinsertid.xml

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 [2013-03-24 16:04 UTC] ichenshy@php.net
Automatic comment from SVN on behalf of ichenshy
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329905
Log: translate pdo/PDOStatement

--
Provided by anonymous #27375 (ichenshy@gmail.com)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC