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--SKIPIF--
11<?php include('skipif.inc'); ?>
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__;
21session_save_path($path);
22session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
23
24session_start();
25$session_id = session_id();
26$_SESSION["Blah"] = "Hello World!";
27$_SESSION["Foo"] = FALSE;
28$_SESSION["Guff"] = 1234567890;
29var_dump($_SESSION);
30
31session_write_close();
32session_unset();
33var_dump($_SESSION);
34
35echo "Starting session again..!\n";
36session_id($session_id);
37session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
38session_start();
39var_dump($_SESSION);
40$_SESSION['Bar'] = 'Foo';
41session_write_close();
42
43echo "Starting session again..!\n";
44session_id($session_id);
45session_set_save_handler("open", "close", "read", "write", "destroy", "gc", "create_sid", "validate_sid", "update");
46session_start();
47var_dump($_SESSION);
48// $_SESSION should be the same and should skip write()
49session_write_close();
50
51echo "Cleanup\n";
52session_start();
53session_destroy();
54
55ob_end_flush();
56?>
57--EXPECTF--
58*** Testing session_set_save_handler() : test write short circuit ***
59Open [%s,PHPSESSID]
60CreateID [PHPT-%s]
61Read [%s,%s]
62array(3) {
63  ["Blah"]=>
64  string(12) "Hello World!"
65  ["Foo"]=>
66  bool(false)
67  ["Guff"]=>
68  int(1234567890)
69}
70Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
71Close [%s,PHPSESSID]
72array(3) {
73  ["Blah"]=>
74  string(12) "Hello World!"
75  ["Foo"]=>
76  bool(false)
77  ["Guff"]=>
78  int(1234567890)
79}
80Starting session again..!
81Open [%s,PHPSESSID]
82Read [%s,%s]
83array(3) {
84  ["Blah"]=>
85  string(12) "Hello World!"
86  ["Foo"]=>
87  bool(false)
88  ["Guff"]=>
89  int(1234567890)
90}
91Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
92Close [%s,PHPSESSID]
93Starting session again..!
94Open [%s,PHPSESSID]
95Read [%s,%s]
96array(4) {
97  ["Blah"]=>
98  string(12) "Hello World!"
99  ["Foo"]=>
100  bool(false)
101  ["Guff"]=>
102  int(1234567890)
103  ["Bar"]=>
104  string(3) "Foo"
105}
106Update [%s,PHPT-%d]
107Close [%s,PHPSESSID]
108Cleanup
109Open [%s,PHPSESSID]
110Read [%s,PHPT-%d]
111Destroy [%s,PHPT-%d]
112Close [%s,PHPSESSID]
113