Browse Source

- A few fixes

- Added register_argv_argc directive to allow disabling of argv/argc
PHP-4.0.5
Zeev Suraski 26 years ago
parent
commit
99f079a349
  1. 5
      NEWS
  2. 14
      ext/session/session.c
  3. 56
      main/main.c
  4. 3
      main/php_globals.h
  5. 2
      main/php_variables.c
  6. 4
      php.ini-dist
  7. 1
      sapi/cgi/cgi_main.c

5
NEWS

@ -2,11 +2,14 @@ PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? ????, 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)

14
ext/session/session.c

@ -181,10 +181,10 @@ static void php_set_session_var(char *name, size_t namelen,
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 @@ static void _php_session_start(PSLS_D)
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 @@ static void _php_session_start(PSLS_D)
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 @@ static void _php_session_start(PSLS_D)
* cookie.
*/
if (gpc_globals &&
if (register_globals &&
!track_vars &&
!PS(id) &&
zend_hash_find(&EG(symbol_table), PS(session_name),

56
main/main.c

@ -97,7 +97,7 @@ static MUTEX_T global_lock;
#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 @@ PHP_INI_BEGIN()
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 @@ static inline void php_register_server_variables(ELS_D SLS_DC PLS_DC)
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 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
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, '+');
@ -1119,11 +1115,27 @@ void _php_build_argv(char *s ELS_DC)
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);
}
}

3
main/php_globals.h

@ -86,7 +86,8 @@ struct _php_core_globals {
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;

2
main/php_variables.c

@ -40,7 +40,7 @@ PHPAPI void php_register_variable(char *val, char *var, pval *track_vars_array E
HashTable *symtable1=NULL;
HashTable *symtable2=NULL;
if (PG(gpc_globals)) {
if (PG(register_globals)) {
symtable1 = EG(active_symbol_table);
}
if (track_vars_array) {

4
php.ini-dist

@ -146,6 +146,10 @@ register_globals = On ; Whether or not to register the EGPCB variables as globa
; 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.

1
sapi/cgi/cgi_main.c

@ -153,6 +153,7 @@ static void sapi_cgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS
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
}

Loading…
Cancel
Save