From: Dmitry Stogov Date: Fri, 23 Mar 2018 12:17:10 +0000 (+0300) Subject: Fixed bug #75982 ($_SERVER mostly empty with default variables_order GPCS on FastCGI... X-Git-Tag: php-7.3.0alpha1~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe6f092e5e60eb165ed4b6db69416ffcdcbd54b7;p=php Fixed bug #75982 ($_SERVER mostly empty with default variables_order GPCS on FastCGI/CGI) --- diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 2682cb674d..2e9cefedea 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -674,15 +674,17 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns static void cgi_php_import_environment_variables(zval *array_ptr) { - if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) { - zend_is_auto_global_str("_ENV", sizeof("_ENV")-1); - } + if (PG(variables_order) && (strchr(PG(variables_order),'E') || strchr(PG(variables_order),'e'))) { + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) { + zend_is_auto_global_str("_ENV", sizeof("_ENV")-1); + } - if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && - Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) { - zend_array_destroy(Z_ARR_P(array_ptr)); - Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_ENV])); - return; + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) { + zend_array_destroy(Z_ARR_P(array_ptr)); + Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_ENV])); + return; + } } /* call php's original import as a catch-all */