mirror of
https://github.com/php/php-src.git
synced 2024-12-12 19:33:31 +08:00
Make the session module more independent
This commit is contained in:
parent
41562f6ca2
commit
7b73aee40f
@ -90,6 +90,7 @@ typedef struct _php_ps_globals {
|
||||
zend_bool auto_start;
|
||||
zend_bool define_sid;
|
||||
zend_bool use_cookies;
|
||||
zend_bool use_trans_sid;
|
||||
} php_ps_globals;
|
||||
|
||||
extern zend_module_entry session_module_entry;
|
||||
@ -148,8 +149,6 @@ void session_adapt_url(const char *, size_t, char **, size_t * TSRMLS_DC);
|
||||
|
||||
void php_set_session_var(char *name, size_t namelen, zval *state_val,HashTable *var_hash TSRMLS_DC);
|
||||
int php_get_session_var(char *name, size_t namelen, zval ***state_var TSRMLS_DC);
|
||||
void php_session_start_output_handler(INIT_FUNC_ARGS, uint chunk_size);
|
||||
void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS);
|
||||
|
||||
int php_session_register_module(ps_module *);
|
||||
|
||||
|
@ -83,6 +83,33 @@ php_ps_globals ps_globals;
|
||||
static ps_module *_php_find_ps_module(char *name TSRMLS_DC);
|
||||
static const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC);
|
||||
|
||||
static void php_session_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
|
||||
{
|
||||
zend_bool do_flush;
|
||||
|
||||
if (mode&PHP_OUTPUT_HANDLER_END) {
|
||||
do_flush=1;
|
||||
}
|
||||
session_adapt_uris(output, output_len, handled_output, handled_output_len, do_flush TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
static void php_session_start_output_handler(INIT_FUNC_ARGS, uint chunk_size)
|
||||
{
|
||||
PHP_RINIT(url_scanner)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
php_start_ob_buffer(NULL, chunk_size TSRMLS_CC);
|
||||
php_ob_set_internal_handler(php_session_output_handler, chunk_size TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
static void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS)
|
||||
{
|
||||
PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RSHUTDOWN(url_scanner)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
}
|
||||
|
||||
|
||||
static PHP_INI_MH(OnUpdateSaveHandler)
|
||||
{
|
||||
PS(mod) = _php_find_ps_module(new_value TSRMLS_CC);
|
||||
@ -123,6 +150,7 @@ PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("session.entropy_length", "0", PHP_INI_ALL, OnUpdateInt, entropy_length, php_ps_globals, ps_globals)
|
||||
STD_PHP_INI_ENTRY("session.cache_limiter", "nocache", PHP_INI_ALL, OnUpdateString, cache_limiter, php_ps_globals, ps_globals)
|
||||
STD_PHP_INI_ENTRY("session.cache_expire", "180", PHP_INI_ALL, OnUpdateInt, cache_expire, php_ps_globals, ps_globals)
|
||||
STD_PHP_INI_ENTRY("session.use_trans_sid", "1", PHP_INI_ALL, OnUpdateBool, use_trans_sid, php_ps_globals, ps_globals)
|
||||
/* Commented out until future discussion */
|
||||
/* PHP_INI_ENTRY("session.encode_sources", "globals,track", PHP_INI_ALL, NULL) */
|
||||
PHP_INI_END()
|
||||
@ -1360,6 +1388,10 @@ PHP_RINIT_FUNCTION(session)
|
||||
php_session_start(TSRMLS_C);
|
||||
}
|
||||
|
||||
if (PS(use_trans_sid)) {
|
||||
php_session_start_output_handler(INIT_FUNC_ARGS_PASSTHRU, 4096);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -1378,6 +1410,9 @@ PHP_FUNCTION(session_write_close)
|
||||
|
||||
PHP_RSHUTDOWN_FUNCTION(session)
|
||||
{
|
||||
if (PS(use_trans_sid)) {
|
||||
php_session_end_output_handler(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
}
|
||||
php_session_flush(TSRMLS_C);
|
||||
php_rshutdown_session_globals(TSRMLS_C);
|
||||
return SUCCESS;
|
||||
@ -1418,34 +1453,6 @@ PHP_MINFO_FUNCTION(session)
|
||||
}
|
||||
|
||||
|
||||
static void php_session_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
|
||||
{
|
||||
zend_bool do_flush;
|
||||
|
||||
if (mode&PHP_OUTPUT_HANDLER_END) {
|
||||
do_flush=1;
|
||||
}
|
||||
session_adapt_uris(output, output_len, handled_output, handled_output_len, do_flush TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
void php_session_start_output_handler(INIT_FUNC_ARGS, uint chunk_size)
|
||||
{
|
||||
memset(&BG(url_adapt_state), 0, sizeof(BG(url_adapt_state)));
|
||||
memset(&BG(url_adapt_state_ex), 0, sizeof(BG(url_adapt_state_ex)));
|
||||
PHP_RINIT(url_scanner)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
php_start_ob_buffer(NULL, chunk_size TSRMLS_CC);
|
||||
php_ob_set_internal_handler(php_session_output_handler, chunk_size TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS)
|
||||
{
|
||||
PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RSHUTDOWN(url_scanner)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
@ -662,7 +662,6 @@ static PHP_INI_MH(OnUpdateSafeModeAllowedEnvVars)
|
||||
PHP_INI_BEGIN()
|
||||
PHP_INI_ENTRY_EX("safe_mode_protected_env_vars", SAFE_MODE_PROTECTED_ENV_VARS, PHP_INI_SYSTEM, OnUpdateSafeModeProtectedEnvVars, NULL)
|
||||
PHP_INI_ENTRY_EX("safe_mode_allowed_env_vars", SAFE_MODE_ALLOWED_ENV_VARS, PHP_INI_SYSTEM, OnUpdateSafeModeAllowedEnvVars, NULL)
|
||||
STD_PHP_INI_ENTRY("session.use_trans_sid", "1", PHP_INI_ALL, OnUpdateBool, use_trans_sid, php_basic_globals, basic_globals)
|
||||
PHP_INI_END()
|
||||
|
||||
|
||||
@ -713,6 +712,9 @@ static void basic_globals_ctor(php_basic_globals *basic_globals_p TSRMLS_DC)
|
||||
zend_hash_init(&BG(sm_protected_env_vars), 5, NULL, NULL, 1);
|
||||
BG(sm_allowed_env_vars) = NULL;
|
||||
|
||||
memset(&BG(url_adapt_state), 0, sizeof(BG(url_adapt_state)));
|
||||
memset(&BG(url_adapt_state_ex), 0, sizeof(BG(url_adapt_state_ex)));
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
CoInitialize(NULL);
|
||||
#endif
|
||||
@ -871,11 +873,6 @@ PHP_RINIT_FUNCTION(basic)
|
||||
PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
|
||||
if (BG(use_trans_sid)) {
|
||||
php_session_start_output_handler(INIT_FUNC_ARGS_PASSTHRU, 4096);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -902,10 +899,6 @@ PHP_RSHUTDOWN_FUNCTION(basic)
|
||||
PHP_RSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
PHP_RSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
|
||||
if (BG(use_trans_sid)) {
|
||||
php_session_end_output_handler(SHUTDOWN_FUNC_ARGS_PASSTHRU);
|
||||
}
|
||||
|
||||
if (BG(user_tick_functions)) {
|
||||
zend_llist_destroy(BG(user_tick_functions));
|
||||
efree(BG(user_tick_functions));
|
||||
|
@ -179,7 +179,6 @@ typedef struct {
|
||||
|
||||
/* var.c */
|
||||
zend_class_entry *incomplete_class;
|
||||
zend_bool use_trans_sid;
|
||||
|
||||
/* url_scanner.c */
|
||||
url_adapt_state_t url_adapt_state;
|
||||
|
Loading…
Reference in New Issue
Block a user