diff options
author | Andrei Zmievski <andrei@php.net> | 2003-10-01 23:11:59 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2003-10-01 23:11:59 +0000 |
commit | b3920d50128bfae5e5b76a1c0b4172b770cd7fc9 (patch) | |
tree | 2b9ee25e60986285291269ee34ede7c02ad66922 /main/php_variables.c | |
parent | dc080a5db6f31c5d174dc0cc097da509c2533142 (diff) | |
download | php-git-b3920d50128bfae5e5b76a1c0b4172b770cd7fc9.tar.gz |
Made the $argc and $argv always available as globals in CLI, and not as
$_SERVER vars which depended on variables_order anyway. No more
silliness.
Diffstat (limited to 'main/php_variables.c')
-rw-r--r-- | main/php_variables.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/main/php_variables.c b/main/php_variables.c index b0dd0c5e52..e20fe4e363 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -369,9 +369,15 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) int count = 0; char *ss, *space; + if (! (PG(register_globals) || SG(request_info).argc || + PG(http_globals)[TRACK_VARS_SERVER]) ) { + return; + } + ALLOC_ZVAL(arr); array_init(arr); - INIT_PZVAL(arr); + arr->is_ref = 0; + arr->refcount = 0; /* Prepare argv */ if (SG(request_info).argc) { /* are we in cli sapi? */ @@ -424,17 +430,20 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) Z_LVAL_P(argc) = count; } Z_TYPE_P(argc) = IS_LONG; - INIT_PZVAL(argc); + argc->is_ref = 0; + argc->refcount = 0; if (PG(register_globals) || SG(request_info).argc) { arr->refcount++; argc->refcount++; zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL); + } else if (!SG(request_info).argc) { + arr->refcount++; + argc->refcount++; + zend_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); + zend_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(pval *), NULL); } - - zend_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); - zend_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(pval *), NULL); } /* }}} */ @@ -476,11 +485,6 @@ static inline void php_register_server_variables(TSRMLS_D) sapi_module.register_server_variables(array_ptr TSRMLS_CC); } - /* argv/argc support */ - if (PG(register_argc_argv)) { - php_build_argv(SG(request_info).query_string, array_ptr TSRMLS_CC); - } - /* PHP Authentication support */ if (SG(request_info).auth_user) { php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, array_ptr TSRMLS_CC); @@ -646,6 +650,11 @@ int php_hash_environment(TSRMLS_D) } } + /* argv/argc support */ + if (PG(register_argc_argv)) { + php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC); + } + for (i=0; i<num_track_vars; i++) { if (jit_initialization && auto_global_records[i].jit_initialization) { continue; |