1--TEST--
2Test session_set_save_handler() function : test lazy_write
3--INI--
4session.use_strict_mode=0
5session.lazy_write=1
6session.save_path=
7session.name=PHPSESSID
8session.gc_probability=0
9session.save_handler=files
10--EXTENSIONS--
11session
12--FILE--
13<?php
14
15ob_start();
16
17echo "*** Testing session_set_save_handler() : test write short circuit ***\n";
18
19require_once "save_handler.inc";
20$path = __DIR__ . '/session_set_save_handler_variation6';
21@mkdir($path);
22session_save_path($path);
23session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
24
25session_start();
26$session_id = session_id();
27$_SESSION["Blah"] = "Hello World!";
28$_SESSION["Foo"] = FALSE;
29$_SESSION["Guff"] = 1234567890;
30var_dump($_SESSION);
31
32session_write_close();
33session_unset();
34var_dump($_SESSION);
35
36echo "Starting session again..!\n";
37session_id($session_id);
38session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
39session_start();
40var_dump($_SESSION);
41$_SESSION['Bar'] = 'Foo';
42session_write_close();
43
44echo "Starting session again..!\n";
45session_id($session_id);
46session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
47session_start();
48var_dump($_SESSION);
49// $_SESSION should be the same and should skip write()
50session_write_close();
51
52echo "Cleanup\n";
53session_start();
54session_destroy();
55
56ob_end_flush();
57?>
58--CLEAN--
59<?php
60$path = __DIR__ . '/session_set_save_handler_variation6';
61rmdir($path);
62?>
63--EXPECTF--
64*** Testing session_set_save_handler() : test write short circuit ***
65Open [%s,PHPSESSID]
66CreateID [PHPT-%s]
67Read [%s,%s]
68array(3) {
69  ["Blah"]=>
70  string(12) "Hello World!"
71  ["Foo"]=>
72  bool(false)
73  ["Guff"]=>
74  int(1234567890)
75}
76Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
77Close [%s,PHPSESSID]
78array(3) {
79  ["Blah"]=>
80  string(12) "Hello World!"
81  ["Foo"]=>
82  bool(false)
83  ["Guff"]=>
84  int(1234567890)
85}
86Starting session again..!
87Open [%s,PHPSESSID]
88Read [%s,%s]
89array(3) {
90  ["Blah"]=>
91  string(12) "Hello World!"
92  ["Foo"]=>
93  bool(false)
94  ["Guff"]=>
95  int(1234567890)
96}
97Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
98Close [%s,PHPSESSID]
99Starting session again..!
100Open [%s,PHPSESSID]
101Read [%s,%s]
102array(4) {
103  ["Blah"]=>
104  string(12) "Hello World!"
105  ["Foo"]=>
106  bool(false)
107  ["Guff"]=>
108  int(1234567890)
109  ["Bar"]=>
110  string(3) "Foo"
111}
112Update [%s,PHPT-%d]
113Close [%s,PHPSESSID]
114Cleanup
115Open [%s,PHPSESSID]
116Read [%s,PHPT-%d]
117Destroy [%s,PHPT-%d]
118Close [%s,PHPSESSID]
119