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 ***
65
66Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
67Open [%s,PHPSESSID]
68CreateID [PHPT-%s]
69Read [%s,%s]
70array(3) {
71  ["Blah"]=>
72  string(12) "Hello World!"
73  ["Foo"]=>
74  bool(false)
75  ["Guff"]=>
76  int(1234567890)
77}
78Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;]
79Close [%s,PHPSESSID]
80array(3) {
81  ["Blah"]=>
82  string(12) "Hello World!"
83  ["Foo"]=>
84  bool(false)
85  ["Guff"]=>
86  int(1234567890)
87}
88Starting session again..!
89
90Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
91Open [%s,PHPSESSID]
92Read [%s,%s]
93array(3) {
94  ["Blah"]=>
95  string(12) "Hello World!"
96  ["Foo"]=>
97  bool(false)
98  ["Guff"]=>
99  int(1234567890)
100}
101Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";]
102Close [%s,PHPSESSID]
103Starting session again..!
104
105Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
106Open [%s,PHPSESSID]
107Read [%s,%s]
108array(4) {
109  ["Blah"]=>
110  string(12) "Hello World!"
111  ["Foo"]=>
112  bool(false)
113  ["Guff"]=>
114  int(1234567890)
115  ["Bar"]=>
116  string(3) "Foo"
117}
118Update [%s,PHPT-%d]
119Close [%s,PHPSESSID]
120Cleanup
121Open [%s,PHPSESSID]
122Read [%s,PHPT-%d]
123Destroy [%s,PHPT-%d]
124Close [%s,PHPSESSID]
125