Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8b51bca

Browse files
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. Closes GH-19870
1 parent 7a63dcc commit 8b51bca

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

‎Zend/zend_compile.c‎

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

20162016
ZEND_HASH_MAP_FOREACH_PTR(CG(auto_globals), auto_global) {
2017-
if (auto_global->jit) {
2018-
auto_global->armed = 1;
2019-
} else if (auto_global->auto_global_callback) {
2017+
auto_global->armed = auto_global->jit || auto_global->auto_global_callback;
2018+
} ZEND_HASH_FOREACH_END();
2019+
2020+
ZEND_HASH_MAP_FOREACH_PTR(CG(auto_globals), auto_global) {
2021+
if (auto_global->armed && !auto_global->jit) {
20202022
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
2021-
} else {
2022-
auto_global->armed = 0;
20232023
}
20242024
} ZEND_HASH_FOREACH_END();
20252025
}
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)

AltStyle によって変換されたページ (->オリジナル) /