[PHP-CVS] [php-src] master: Fix GH-23056: missing handler name in session write warning (#23059)

[email protected] (Lazizbek Ergashev via GitHub)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: Lazizbek Ergashev (lazerg)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-08-18T20:47:59+01:00

Commit: https://github.com/php/php-src/commit/90b43f04bf377584913206670e2c49e3f037cf09
Raw diff: https://github.com/php/php-src/commit/90b43f04bf377584913206670e2c49e3f037cf09.diff

Fix GH-23056: missing handler name in session write warning (#23059)

Closes GH-23056

Changed paths:
  M  ext/session/session.c
  M  ext/session/tests/user_session_module/gh23043.phpt


Diff:

diff --git a/ext/session/session.c b/ext/session/session.c
index e745a628767f..6a9f2b355c12 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.