diff options
-rw-r--r-- | main/main.c | 10 | ||||
-rw-r--r-- | main/php_variables.c | 8 | ||||
-rw-r--r-- | main/php_variables.h | 2 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 5 |
4 files changed, 15 insertions, 10 deletions
diff --git a/main/main.c b/main/main.c index 3a8af10da3..2ef64e9af1 100644 --- a/main/main.c +++ b/main/main.c @@ -1015,7 +1015,10 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC) } else { p = PG(gpc_order); have_variables_order=0; - php_import_environment_variables(ELS_C PLS_CC); + ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]); + array_init(PG(http_globals)[TRACK_VARS_ENV]); + INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]); + php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] ELS_CC PLS_CC); } while(p && *p) { @@ -1044,7 +1047,10 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC) case 'e': case 'E': if (have_variables_order) { - php_import_environment_variables(ELS_C PLS_CC); + ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]); + array_init(PG(http_globals)[TRACK_VARS_ENV]); + INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]); + php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] ELS_CC PLS_CC); } else { php_error(E_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead"); } diff --git a/main/php_variables.c b/main/php_variables.c index bff78e4a79..08a201e874 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -301,15 +301,9 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC) -void php_import_environment_variables(ELS_D PLS_DC) +void php_import_environment_variables(zval *array_ptr ELS_DC PLS_DC) { char **env, *p, *t; - zval *array_ptr=NULL; - - ALLOC_ZVAL(array_ptr); - array_init(array_ptr); - INIT_PZVAL(array_ptr); - PG(http_globals)[TRACK_VARS_ENV] = array_ptr; for (env = environ; env != NULL && *env != NULL; env++) { p = strchr(*env, '='); diff --git a/main/php_variables.h b/main/php_variables.h index f71fe2762b..bd0a98810a 100644 --- a/main/php_variables.h +++ b/main/php_variables.h @@ -31,7 +31,7 @@ #define PARSE_STRING 3 void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC); -void php_import_environment_variables(ELS_D PLS_DC); +PHPAPI void php_import_environment_variables(zval *array_ptr ELS_DC PLS_DC); PHPAPI void php_register_variable(char *var, char *val, pval *track_vars_array ELS_DC PLS_DC); PHPAPI void php_register_variable_ex(char *var, zval *val, pval *track_vars_array ELS_DC PLS_DC); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index c320fa2891..67ed3b80b5 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -148,6 +148,11 @@ static void sapi_cgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS { char *pi; + /* In CGI mode, we consider the environment to be a part of the server + * variables + */ + php_import_environment_variables(track_vars_array ELS_CC PLS_CC); + /* Build the special-case PHP_SELF variable for the CGI version */ #if FORCE_CGI_REDIRECT php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array ELS_CC PLS_CC); |