|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? ????, 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)
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));
}
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;
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;
}
* cookie.
*/
- if (gpc_globals &&
+ if (register_globals &&
!track_vars &&
!PS(id) &&
zend_hash_find(&EG(symbol_table), PS(session_name),
#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);
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)
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);
+ }
}
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, '+');
ss = space;
}
}
- 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);
+
+ /* 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);
+ }
+
}