Skip to content

Commit 6f3b163

Browse files
committed
ext/session: add mod_user_uses_object_methods_as_handlers global
This solves the use case of knowing if the session handlers are methods of an object or individual handlers without relying on the now removed mod_user_names global.
1 parent 4633a58 commit 6f3b163

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES
104104

105105
- ext/session:
106106
. php_session_flush() now returns a bool rather than a zend_result.
107+
. The mod_user_names global has been removed.
108+
. The mod_user_uses_object_methods_as_handlers global has been added,
109+
it indicates whether the session handlers are methods of an object or not.
107110
. Removed session_adapt_url().
108111
. PS_OPEN_ARGS is now defined as
109112
`void **mod_data, zend_string *save_path, zend_string *session_name`

ext/session/php_session.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ typedef struct _php_ps_globals {
184184

185185
bool mod_user_implemented;
186186
bool mod_user_is_open;
187+
bool mod_user_uses_object_methods_as_handlers;
187188
bool use_trans_sid; /* contains the INI value of whether to use trans-sid */
188189
} php_ps_globals;
189190

ext/session/session.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ static inline void php_rinit_session_globals(void)
118118
PS(set_handler) = false;
119119
PS(mod_data) = NULL;
120120
PS(mod_user_is_open) = false;
121+
PS(mod_user_uses_object_methods_as_handlers) = false;
121122
PS(define_sid) = true;
122123
PS(session_vars) = NULL;
123124
PS(module_number) = my_module_number;
@@ -2126,6 +2127,7 @@ PHP_FUNCTION(session_set_save_handler)
21262127
zend_string_release_ex(validate_sid_name, false);
21272128
zend_string_release_ex(update_timestamp_name, false);
21282129

2130+
PS(mod_user_uses_object_methods_as_handlers) = true;
21292131
if (register_shutdown) {
21302132
/* create shutdown function */
21312133
php_shutdown_function_entry shutdown_function_entry = {
@@ -2217,6 +2219,7 @@ PHP_FUNCTION(session_set_save_handler)
22172219
SESSION_SET_USER_HANDLER_PROCEDURAL_OPTIONAL(ps_validate_sid, validate_id_fci);
22182220
SESSION_SET_USER_HANDLER_PROCEDURAL_OPTIONAL(ps_update_timestamp, update_timestamp_fci);
22192221

2222+
PS(mod_user_uses_object_methods_as_handlers) = false;
22202223
RETURN_TRUE;
22212224
}
22222225

@@ -2843,6 +2846,7 @@ static PHP_GINIT_FUNCTION(ps)
28432846
ps_globals->default_mod = NULL;
28442847
ps_globals->mod_user_implemented = false;
28452848
ps_globals->mod_user_is_open = false;
2849+
ps_globals->mod_user_uses_object_methods_as_handlers = false;
28462850
ps_globals->session_vars = NULL;
28472851
ps_globals->set_handler = false;
28482852
ps_globals->session_started_filename = NULL;

0 commit comments

Comments
 (0)