From 00c81b0e494914805f4a06692bf2654ed9bab0b6 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 20 Mar 2006 10:18:50 +0000 Subject: [PATCH] Fixed register_argc_argv behavior. Now it behave in the same way as before in combinations with variables_order and auto_globals_jit. $argc and $argv global variables are registered only in CLI mode and under $_SERVER[] in other case. (This is done because register_globals was removed and assumed - off). --- main/php_variables.c | 33 +++++++++++++++++++-------------- tests/basic/011.phpt | 4 ++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/main/php_variables.c b/main/php_variables.c index 2bfe566a1a..e0a984c939 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -639,7 +639,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) int count = 0; char *ss, *space; - if (!(SG(request_info).argc || (s && *s))) { + if (!(SG(request_info).argc || track_vars_array)) { return; } @@ -696,7 +696,7 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) argc->is_ref = 0; argc->refcount = 0; - if (Z_LVAL_P(argc)) { + if (SG(request_info).argc) { arr->refcount++; argc->refcount++; zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); @@ -920,6 +920,23 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS { if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) { php_register_server_variables(TSRMLS_C); + + if (PG(register_argc_argv)) { + if (SG(request_info).argc) { + zval **argc, **argv; + + if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS && + zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) { + (*argc)->refcount++; + (*argv)->refcount++; + zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL); + zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), argc, sizeof(zval *), NULL); + } + } else { + php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC); + } + } + } else { zval *server_vars=NULL; ALLOC_ZVAL(server_vars); @@ -934,18 +951,6 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); PG(http_globals)[TRACK_VARS_SERVER]->refcount++; - if (PG(register_argc_argv)) { - zval **argc, **argv; - - if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS && - zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) { - (*argc)->refcount++; - (*argv)->refcount++; - zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL); - zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), argc, sizeof(zval *), NULL); - } - } - return 0; /* don't rearm */ } diff --git a/tests/basic/011.phpt b/tests/basic/011.phpt index 14c0542ec1..68264afdd2 100644 --- a/tests/basic/011.phpt +++ b/tests/basic/011.phpt @@ -8,8 +8,8 @@ register_argc_argv=1 ab+cd+ef+123+test --FILE-- --EXPECT-- -- 2.40.0