|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37381 auto_globals_jit fails to correctly intialize variables
Submitted: 2006-05-09 14:14 UTC Modified: 2006-06-01 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: gcp at sjeng dot org Assigned:
Status: No Feedback Package: Variables related
PHP Version: 5.1.4 OS: FreeBSD 6.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: gcp at sjeng dot org
New email:
PHP Version: OS:


 [2006-05-09 14:14 UTC] gcp at sjeng dot org
In some circumstances, global variables will fail to be initialized when auto_globals_jit is enabled (the default). This is a regression, the problem did not exist in 5.1.2.

php.ini is default recommended one. Server is lighttpd 1.4.11 using PHP in FastCGI mode. 

Reproduce code:
Using for example, phpMyAdmin, and looking in the 
libaries/Config.class.php code:

 function checkPmaAbsoluteUri()
        // Setup a default value to let the people and lazy syadmins work anyway,
        // they'll get an error if the autodetect code doesn't work
        $pma_absolute_uri = $this->get('PmaAbsoluteUri');
        if ( strlen($pma_absolute_uri) < 1 ) {
            $url = array();
            // At first we try to parse REQUEST_URI, it might contain full URI
            if ( ! empty($_SERVER['REQUEST_URI'] ) ) {
                $url = parse_url($_SERVER['REQUEST_URI']);

            // If we don't have scheme, we didn't have full URL so we need to
            // dig deeper
            if ( empty( $url['scheme'] ) ) {
                // Scheme
                if ( ! empty( $_SERVER['HTTP_SCHEME'] ) ) {
                    $url['scheme'] = $_SERVER['HTTP_SCHEME'];
                } else {
                    $url['scheme'] =
                        !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off'
                            ? 'https'
                            : 'http';

It's possible to enter this function with $_SERVER missing essential things such as HTTP_HOST:

array(4) {
string(21) "/mysqladmin/index.php"
["PHP_AUTH_USER"]=> (censored)
["PHP_AUTH_PW"]=> (censored)

If auto_global_jit is disabled, this does not not happen, and HTTP_HOST etc are set correctly.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-10 10:14 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

 [2006-05-10 11:19 UTC] gcp at sjeng dot org
I don't know of any small testcase. As indicated, this is 100% a regression in PHP 5.1.3 or 5.1.4 compared to 5.1.2, it's possible to make it appear/disappear by toggling the indicated PHP setting, and it happens with a very popular PHP package, in the routine mentioned earlier.

I can provide help tracing the issue, but I do not have a "10-20 line reproducible case".
 [2006-05-24 21:59 UTC]
Unfortunately, I don't think anybody will be able to find time to debug phpMyAdmin.
So please provide a short but complete reproduce script to speedup the resolution of the issue.
 [2006-06-01 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-06-09 10:57 UTC] me at thomaskeller dot biz
I've encountered the same problem, with a normal rpm installation of php-5.1.4-1 which ships with FC5.

A simple reproducable script would be

<? var_dump($_SERVER); ?>

which returns NULL if auto_globals_jit is set to on (default in this rpm package). This is the same deal with $_REQUEST, which is also NULL.

Now, even if auto_globals_jit is set to false, $_GLOBALS is still not available.
 [2006-06-09 11:01 UTC] me at thomaskeller dot biz
I forgot to mention: I'm using the apache2handler with httpd-2.2.0
 [2007-07-07 01:38 UTC] php at modem-help dot com
PHP 5.1.6
(RedHat FC6; std PHP, Apache; fully updated)

`auto_globals_jit = On' works fine with 'normal' PHP scripts. However, when included via `auto_prepend_file' $_SERVER is completely absent (together with other Globals).

Test case:

file script:
if( !empty( $GLOBALS[ '_SERVER' ])) {
} elseif( !empty( $GLOBALS[ 'HTTP_SERVER_VARS' ])) {
} else {

global ${$_SERVER_ARRAY};

$ipRemote = ${$_SERVER_ARRAY}[ 'REMOTE_ADDR' ];

<IfModule mod_php5.c>
   AddType   application/x-httpd-php .html
   php_value auto_prepend_file "/path/to/test/file"

variables_order = "EGPCS"
register_globals = Off
register_long_arrays = Off
register_argc_argv = On
auto_globals_jit = On

The above produces nothing ($_SERVER is absent). Change `auto_globals_jit' to `Off' (plus `apachectl graceful') and it works.

Time to pay attention to this, folks.

- Alex Kemp
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 13:03:41 2021 UTC