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