From 8a586103fc414b6a381bf7f7066a8de22ddade3c Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Thu, 3 Oct 2002 04:53:05 +0000 Subject: [PATCH] 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. --- ext/session/session.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ext/session/session.c b/ext/session/session.c index 8353aa73d59..4d9afd26bb0 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -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