Skip to content

Commit fe6f092

Browse files
committed
Fixed bug #75982 ($_SERVER mostly empty with default variables_order GPCS on FastCGI/CGI)
1 parent 295b233 commit fe6f092

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

sapi/cgi/cgi_main.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,15 +674,17 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns
674674

675675
static void cgi_php_import_environment_variables(zval *array_ptr)
676676
{
677-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) {
678-
zend_is_auto_global_str("_ENV", sizeof("_ENV")-1);
679-
}
677+
if (PG(variables_order) && (strchr(PG(variables_order),'E') || strchr(PG(variables_order),'e'))) {
678+
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) {
679+
zend_is_auto_global_str("_ENV", sizeof("_ENV")-1);
680+
}
680681

681-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
682-
Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) {
683-
zend_array_destroy(Z_ARR_P(array_ptr));
684-
Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_ENV]));
685-
return;
682+
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
683+
Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) {
684+
zend_array_destroy(Z_ARR_P(array_ptr));
685+
Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_ENV]));
686+
return;
687+
}
686688
}
687689

688690
/* call php's original import as a catch-all */

0 commit comments

Comments
 (0)