From: support at spill dot nl Operating system: RHL 8.0 PHP version: 4.3.3 PHP Bug Type: Documentation problem Bug description: user session write handler called even if session contains no data
Description: ------------ The documentation at php.net for session_set_save_handler() states the following note: The write handler is not executed if the session contains no data; this applies even if empty session variables are registered. This differs to the default file-based session save handler, which creates empty session files. http://php.net/session_set_save_handler The documentation at Zend.com contains a similar statement. However the most simple user session handler I can come up with reports the write function being called with absolutely no registered variables. I think this is good behaviour as the user session handler should decide for itself what to do with empty data, but the documentation should be fixed if this is expected behaviour. Reproduce code: --------------- <?php // bogus session handler function open($save_path,$session_name) { return(error_log("sess_open('".$save_path."','".$session_name."')",0)); } function close() { return(error_log("sess_close()",0)); } function read($id) { error_log("sess_read('".$id."')",0); return(""); } function write($id,$sess_data) { return(error_log("sess_write('".$id."','".$sess_data."')",0)); } function destroy($id) { return(error_log("sess_destroy('".$id."')",0)); } function gc($maxlifetime) { return(error_log("sess_gc('".$maxlifetime."')",0)); } // install session handler session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); // start a session session_start(); ?> Expected result: ---------------- I would expect the following lines in my logfile: [22-Oct-2003 17:44:22] sess_open('/bigdisk/tmp/php','PHPSESSID') [22-Oct-2003 17:44:22] sess_read('dd2340d600efe2925b4d8007ae8fbbd2') [22-Oct-2003 17:44:22] sess_close() Actual result: -------------- However I find: [22-Oct-2003 17:44:22] sess_open('/bigdisk/tmp/php','PHPSESSID') [22-Oct-2003 17:44:22] sess_read('dd2340d600efe2925b4d8007ae8fbbd2') [22-Oct-2003 17:44:22] sess_write('dd2340d600efe2925b4d8007ae8fbbd2','') [22-Oct-2003 17:44:22] sess_close() The call to write() is unexpected as the documentation states it will not be called under these circumstances. -- Edit bug report at http://bugs.php.net/?id=25954&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25954&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25954&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25954&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25954&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25954&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25954&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25954&r=support Expected behavior: http://bugs.php.net/fix.php?id=25954&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25954&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25954&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25954&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25954&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25954&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25954&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25954&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25954&r=float