1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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
This commit is contained in:
Ilija Tovilo
2025-09-18 11:57:38 +02:00
parent 59bfaa65c4
commit 9bc35f1982
3 changed files with 23 additions and 5 deletions

1
NEWS
View File

@@ -18,6 +18,7 @@ PHP NEWS
. Fixed bug GH-19480 (error_log php.ini cannot be unset when open_basedir is
configured). (nielsdos)
. Fixed bug GH-20002 (Broken build on *BSD with MSAN). (outtersg)
. Fixed bug GH-19934 (CGI with auto_globals_jit=0 causes uouv). (ilutov)
- CLI:
. Fix useless "Failed to poll event" error logs due to EAGAIN in CLI server

View File

@@ -1938,12 +1938,12 @@ ZEND_API void zend_activate_auto_globals(void) /* {{{ */
zend_auto_global *auto_global;
ZEND_HASH_MAP_FOREACH_PTR(CG(auto_globals), auto_global) {
if (auto_global->jit) {
auto_global->armed = 1;
} else if (auto_global->auto_global_callback) {
auto_global->armed = auto_global->jit || auto_global->auto_global_callback;
} ZEND_HASH_FOREACH_END();
ZEND_HASH_MAP_FOREACH_PTR(CG(auto_globals), auto_global) {
if (auto_global->armed && !auto_global->jit) {
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
} else {
auto_global->armed = 0;
}
} ZEND_HASH_FOREACH_END();
}

View File

@@ -0,0 +1,17 @@
--TEST--
CGI with auto_globals_jit=0
--INI--
auto_globals_jit=0
--CGI--
--ENV--
FOO=BAR
--FILE--
<?php
var_dump($_SERVER['FOO']);
var_dump($_ENV['FOO']);
var_dump(getenv('FOO'));
?>
--EXPECT--
string(3) "BAR"
string(3) "BAR"
string(3) "BAR"