cvs: /php4 NEWS main.c php.ini-dist php_globals.h php_variables.c /php4/ext/session session.c /php4/sapi/cgi cgi_main.c

From: Date: Fri, 28 Jan 2000 18:29:38 +0000
Subject: cvs: /php4 NEWS main.c php.ini-dist php_globals.h php_variables.c /php4/ext/session session.c /php4/sapi/cgi cgi_main.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-9530@lists.php.net to get a copy of this message
zeev Fri Jan 28 10:29:38 2000 EDT Modified files: /php4 NEWS main.c php.ini-dist php_globals.h php_variables.c /php4/ext/session session.c /php4/sapi/cgi cgi_main.c Log: - A few fixes - Added register_argv_argc directive to allow disabling of argv/argc Index: php4/NEWS diff -u php4/NEWS:1.105 php4/NEWS:1.106 --- php4/NEWS:1.105 Fri Jan 28 09:24:49 2000 +++ php4/NEWS Fri Jan 28 10:29:37 2000 @@ -2,11 +2,14 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ?? ????, Version 4.0 Beta 4 +- Added register_argc_argv INI directive, to allow to selectively disable + the declaration of the $argv and $argc variables for increased + performance (Zeev) - Added $HTTP_ENV_VARS[] and $HTTP_SERVER_VARS[] support, which similarly to $HTTP_GET_VARS[], contain environment and server variables. Setting register_globals to Off will now also prevent registration of the environment and server variables into the global scope (Zeev) -- Renamed gpc_globals to register_globals (Zeev) +- Renamed gpc_globals INI directive to register_globals (Zeev) - Introduced variables_order that deprecates gpc_order, and allows control over the server and environment variables, in addition to GET/POST/Cookies (Zeev) Index: php4/main.c diff -u php4/main.c:1.185 php4/main.c:1.186 --- php4/main.c:1.185 Fri Jan 28 09:43:41 2000 +++ php4/main.c Fri Jan 28 10:29:37 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.185 2000/01/28 17:43:41 zeev Exp $ */ +/* $Id: main.c,v 1.186 2000/01/28 18:29:37 zeev Exp $ */ #include <stdio.h> @@ -97,7 +97,7 @@ #endif -void _php_build_argv(char * ELS_DC); +static void php_build_argv(char *s, zval *track_vars_array ELS_DC PLS_DC); static void php_timeout(int dummy); static void php_set_timeout(long seconds); @@ -250,7 +250,8 @@ STD_PHP_INI_BOOLEAN("track_vars", "0", PHP_INI_ALL, OnUpdateBool, track_vars, php_core_globals, core_globals) #endif - STD_PHP_INI_BOOLEAN("register_globals", "1", PHP_INI_ALL, OnUpdateBool, gpc_globals, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("register_globals", "1", PHP_INI_ALL, OnUpdateBool, register_globals, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_ALL, OnUpdateBool, register_argc_argv, php_core_globals, core_globals) STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals) STD_PHP_INI_ENTRY("variables_order", NULL, PHP_INI_ALL, OnUpdateStringUnempty, variables_order, php_core_globals, core_globals) STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals) @@ -1007,6 +1008,10 @@ zend_hash_add(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), &array_ptr, sizeof(pval *),NULL); } sapi_module.register_server_variables(array_ptr ELS_CC SLS_CC PLS_CC); + + if (PG(register_argc_argv)) { + php_build_argv(SG(request_info).query_string, array_ptr ELS_CC PLS_CC); + } } @@ -1070,30 +1075,21 @@ php_register_server_variables(ELS_C SLS_CC PLS_CC); } - - /* need argc/argv support as well */ - _php_build_argv(SG(request_info).query_string ELS_CC); - return SUCCESS; } -void _php_build_argv(char *s ELS_DC) +static void php_build_argv(char *s, zval *track_vars_array ELS_DC PLS_DC) { - pval *arr, *tmp; + pval *arr, *argc, *tmp; int count = 0; char *ss, *space; ALLOC_ZVAL(arr); - arr->value.ht = (HashTable *) emalloc(sizeof(HashTable)); - if (zend_hash_init(arr->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0) == FAILURE) { - php_error(E_WARNING, "Unable to create argv array"); - } else { - arr->type = IS_ARRAY; - INIT_PZVAL(arr); - zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); - } - /* now pick out individual entries */ + array_init(arr); + INIT_PZVAL(arr); + + /* Prepare argv */ ss = s; while (ss) { space = strchr(ss, '+'); @@ -1118,12 +1114,28 @@ } else { ss = space; } + } + + /* prepare argc */ + ALLOC_ZVAL(argc); + argc->value.lval = count; + argc->type = IS_LONG; + INIT_PZVAL(argc); + + if (PG(register_globals)) { + zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); + zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(pval *), NULL); + } + + if (PG(track_vars)) { + if (!PG(register_globals)) { + arr->refcount++; + argc->refcount++; + } + zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); + zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(pval *), NULL); } - ALLOC_ZVAL(tmp); - tmp->value.lval = count; - tmp->type = IS_LONG; - INIT_PZVAL(tmp); - zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &tmp, sizeof(pval *), NULL); + } Index: php4/php.ini-dist diff -u php4/php.ini-dist:1.19 php4/php.ini-dist:1.20 --- php4/php.ini-dist:1.19 Fri Jan 28 09:24:49 2000 +++ php4/php.ini-dist Fri Jan 28 10:29:37 2000 @@ -146,6 +146,10 @@ ; most sense when coupled with track_vars - in which case you can ; access all of the GPC variables through the $HTTP_*_VARS[], ; variables. +register_argv_argc = On ; This directive tells PHP whether to declare the argv&argc + ; variables (that would contain the GET information). If you + ; don't use these variables, you should turn it off for + ; increased performance track_vars = On ; enable the $HTTP_*_VARS[] arrays, where * is one of ; ENV, POST, GET, COOKIE or SERVER. gpc_order = "GPC" ; This directive is deprecated. Use variables_order instead. Index: php4/php_globals.h diff -u php4/php_globals.h:1.37 php4/php_globals.h:1.38 --- php4/php_globals.h:1.37 Fri Jan 28 09:24:49 2000 +++ php4/php_globals.h Fri Jan 28 10:29:37 2000 @@ -86,7 +86,8 @@ zend_bool expose_php; zend_bool track_vars; - zend_bool gpc_globals; + zend_bool register_globals; + zend_bool register_argc_argv; zend_bool y2k_compliance; Index: php4/php_variables.c diff -u php4/php_variables.c:1.1 php4/php_variables.c:1.2 --- php4/php_variables.c:1.1 Fri Jan 28 09:24:49 2000 +++ php4/php_variables.c Fri Jan 28 10:29:37 2000 @@ -40,7 +40,7 @@ HashTable *symtable1=NULL; HashTable *symtable2=NULL; - if (PG(gpc_globals)) { + if (PG(register_globals)) { symtable1 = EG(active_symbol_table); } if (track_vars_array) { Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.99 php4/ext/session/session.c:1.100 --- php4/ext/session/session.c:1.99 Mon Jan 17 14:41:59 2000 +++ php4/ext/session/session.c Fri Jan 28 10:29:37 2000 @@ -181,10 +181,10 @@ zval_copy_ctor(state_val_copy); state_val_copy->refcount = 0; - if (PG(gpc_globals) && PG(track_vars)) { + if (PG(register_globals) && PG(track_vars)) { zend_set_hash_symbol(state_val_copy, name, namelen, 1, 2, PS(http_state_vars)->value.ht, &EG(symbol_table)); } else { - if (PG(gpc_globals)) { + if (PG(register_globals)) { zend_set_hash_symbol(state_val_copy, name, namelen, 0, 1, &EG(symbol_table)); } @@ -639,7 +639,7 @@ char *p; int send_cookie = 1; int define_sid = 1; - zend_bool gpc_globals; + zend_bool register_globals; zend_bool track_vars; int module_number = PS(module_number); int nrand; @@ -650,11 +650,11 @@ lensess = strlen(PS(session_name)); - gpc_globals = INI_BOOL("gpc_globals"); + register_globals = INI_BOOL("register_globals"); track_vars = INI_BOOL("track_vars"); - if (!gpc_globals && !track_vars) { - php_error(E_ERROR, "The sessions module will not work, if you have disabled track_vars and gpc_globals. Enable at least one of them."); + if (!register_globals && !track_vars) { + php_error(E_ERROR, "The sessions module will not work, if you have disabled track_vars and register_globals. Enable at least one of them."); return; } @@ -669,7 +669,7 @@ * cookie. */ - if (gpc_globals && + if (register_globals && !track_vars && !PS(id) && zend_hash_find(&EG(symbol_table), PS(session_name), Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.16 php4/sapi/cgi/cgi_main.c:1.17 --- php4/sapi/cgi/cgi_main.c:1.16 Fri Jan 28 09:24:51 2000 +++ php4/sapi/cgi/cgi_main.c Fri Jan 28 10:29:37 2000 @@ -153,6 +153,7 @@ val = emalloc(l + 1); php_sprintf(val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE */ php_register_variable(val, "PHP_SELF", track_vars_array ELS_CC PLS_CC); + efree(val); } #endif }

« previous php.version4 (#9530) next »