Skip to content

Commit 9bc35f1

Browse files
committed
Fix CGI with auto_globals_jit=0
In CGI, php_auto_globals_create_server() (i.e. auto_global_callback() here) initializes $_ENV to reuse for $_SERVER. However, because $_SERVER is constructed first, we have not yet initialized auto_global->armed of the $_ENV global. Split the loop into initialization and constructor phases. Fixes GH-19934 Closes GH-19870
1 parent 59bfaa6 commit 9bc35f1

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818
. Fixed bug GH-19480 (error_log php.ini cannot be unset when open_basedir is
1919
configured). (nielsdos)
2020
. Fixed bug GH-20002 (Broken build on *BSD with MSAN). (outtersg)
21+
. Fixed bug GH-19934 (CGI with auto_globals_jit=0 causes uouv). (ilutov)
2122

2223
- CLI:
2324
. Fix useless "Failed to poll event" error logs due to EAGAIN in CLI server

Zend/zend_compile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,12 +1938,12 @@ ZEND_API void zend_activate_auto_globals(void) /* {{{ */
19381938
zend_auto_global *auto_global;
19391939

19401940
ZEND_HASH_MAP_FOREACH_PTR(CG(auto_globals), auto_global) {
1941-
if (auto_global->jit) {
1942-
auto_global->armed = 1;
1943-
} else if (auto_global->auto_global_callback) {
1941+
auto_global->armed = auto_global->jit || auto_global->auto_global_callback;
1942+
} ZEND_HASH_FOREACH_END();
1943+
1944+
ZEND_HASH_MAP_FOREACH_PTR(CG(auto_globals), auto_global) {
1945+
if (auto_global->armed && !auto_global->jit) {
19441946
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
1945-
} else {
1946-
auto_global->armed = 0;
19471947
}
19481948
} ZEND_HASH_FOREACH_END();
19491949
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
CGI with auto_globals_jit=0
3+
--INI--
4+
auto_globals_jit=0
5+
--CGI--
6+
--ENV--
7+
FOO=BAR
8+
--FILE--
9+
<?php
10+
var_dump($_SERVER['FOO']);
11+
var_dump($_ENV['FOO']);
12+
var_dump(getenv('FOO'));
13+
?>
14+
--EXPECT--
15+
string(3) "BAR"
16+
string(3) "BAR"
17+
string(3) "BAR"

0 commit comments

Comments
 (0)