Align behaviour with 4.2 with regard to register_globals=1

session_register("c");
unset($c);
$c = time();

If a user unsets a global session variable, it is not a reference
to a $_SESSION slot anymore.

During serialization, PHP 4.2 will not find the respective entry in
$_SESSION and fall back to the global sym table.
This commit is contained in:
Sascha Schumann 2002-10-03 04:53:05 +00:00
parent f534dc8f47
commit 8a586103fc

View file

@ -317,12 +317,32 @@ void php_set_session_var(char *name, size_t namelen, zval *state_val, php_unseri
int php_get_session_var(char *name, size_t namelen, zval ***state_var TSRMLS_DC)
{
int ret = FAILURE;
IF_SESSION_VARS() {
return zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name,
ret = zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name,
namelen+1, (void **) state_var);
/*
* If register_globals is enabled, and
* if there is an entry for the slot in $_SESSION, and
* if that entry is still set to NULL, and
* if the global var exists, then
* we prefer the same key in the global sym table
*/
if (PG(register_globals) && ret == SUCCESS
&& Z_TYPE_PP(*state_var) == IS_NULL) {
zval **tmp;
if (zend_hash_find(&EG(symbol_table), name, namelen + 1,
(void **) &tmp) == SUCCESS) {
*state_var = tmp;
}
}
}
return FAILURE;
return ret;
}
#define PS_BIN_NR_OF_BITS 8