1--TEST-- 2updateTimestamp never called when session data is empty 3--EXTENSIONS-- 4session 5--SKIPIF-- 6<?php include('skipif.inc'); ?> 7--INI-- 8session.use_strict_mode=0 9session.save_handler=files 10--XFAIL-- 11Current session module is designed to write empty session always. In addition, current session module only supports SessionHandlerInterface only from PHP 7.0. 12--FILE-- 13<?php 14class MySessionHandler extends SessionHandler implements SessionUpdateTimestampHandlerInterface 15{ 16 public function open($path, $sessname): bool { 17 return TRUE; 18 } 19 20 public function close(): bool { 21 return TRUE; 22 } 23 24 public function read($sessid): string|false { 25 return ''; 26 } 27 28 public function write($sessid, $sessdata): bool { 29 echo __FUNCTION__, PHP_EOL; 30 return TRUE; 31 } 32 33 public function destroy($sessid): bool { 34 return TRUE; 35 } 36 37 public function gc($maxlifetime): int|false { 38 return TRUE; 39 } 40 41 public function create_sid(): string { 42 return sha1(random_bytes(32)); 43 } 44 45 public function validateId($sid): bool { 46 return TRUE; 47 } 48 49 public function updateTimestamp($sessid, $sessdata): bool { 50 echo __FUNCTION__, PHP_EOL; 51 return TRUE; 52 } 53} 54 55ob_start(); 56$handler = new MySessionHandler(); 57session_set_save_handler($handler); 58 59session_id(sha1('')); 60var_dump(session_id()); 61var_dump(session_start(['lazy_write'=>1])); 62session_commit(); 63 64session_id(sha1('')); 65var_dump(session_id()); 66var_dump(session_start(['lazy_write'=>1])); 67session_commit(); 68 69session_id(sha1('')); 70var_dump(session_id()); 71var_dump(session_start(['lazy_write'=>0])); 72session_commit(); 73?> 74--EXPECT-- 75string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" 76bool(true) 77write 78string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" 79bool(true) 80updateTimestamp 81string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" 82bool(true) 83write 84