Skip to content

Commit 147bfc8

Browse files
committed
Fix CGI with auto_globals_jit=0
There's no need to call zend_is_auto_global(), which will read the uninitialized armed field. If the env is not yet initialized, we'll fall back to php_php_import_environment_variables().
1 parent 6eb3fae commit 147bfc8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

sapi/cgi/cgi_main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,6 @@ static void cgi_php_load_env_var(const char *var, unsigned int var_len, char *va
664664
static void cgi_php_import_environment_variables(zval *array_ptr)
665665
{
666666
if (PG(variables_order) && (strchr(PG(variables_order),'E') || strchr(PG(variables_order),'e'))) {
667-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) {
668-
zend_is_auto_global(ZSTR_KNOWN(ZEND_STR_AUTOGLOBAL_ENV));
669-
}
670-
671667
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
672668
Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) {
673669
zend_array_destroy(Z_ARR_P(array_ptr));
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)