From a4aab1e0ed3573d1540d1c4702098f77bc0facfd Mon Sep 17 00:00:00 2001 From: lazerg Date: Wed, 5 Aug 2026 14:37:19 +0500 Subject: [PATCH] Fix GH-23056: missing handler name in session write warning --- ext/session/session.c | 5 ++++- ext/session/tests/user_session_module/gh23043.phpt | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/session/session.c b/ext/session/session.c index 5711f0daf216..72219a3fa7e0 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -531,7 +531,10 @@ static void php_session_save_current_state(bool write) && zend_string_equals(val, PS(session_vars)) ) { ret = PS(mod)->s_update_timestamp(&PS(mod_data), PS(id), val, PS(gc_maxlifetime)); - handler_function = &PS(mod_user_names).ps_update_timestamp; + /* The user handler falls back to the write handler if no update timestamp handler is set */ + if (!Z_ISUNDEF(PS(mod_user_names).ps_update_timestamp)) { + handler_function = &PS(mod_user_names).ps_update_timestamp; + } } else { ret = PS(mod)->s_write(&PS(mod_data), PS(id), val, PS(gc_maxlifetime)); } diff --git a/ext/session/tests/user_session_module/gh23043.phpt b/ext/session/tests/user_session_module/gh23043.phpt index dc3676993903..e3528884a79a 100644 --- a/ext/session/tests/user_session_module/gh23043.phpt +++ b/ext/session/tests/user_session_module/gh23043.phpt @@ -27,9 +27,9 @@ string(0) "" Warning: SessionHandler::write(): Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed in %s on line %d -Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: , handler: ) in %s on line %d +Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: , handler: a::write) in %s on line %d string(0) "" Warning: SessionHandler::write(): Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed in Unknown on line 0 -Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: , handler: ) in Unknown on line 0 +Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: , handler: a::write) in Unknown on line 0