1--TEST--
2Test session_set_save_handler() function : variation
3--INI--
4session.use_strict_mode=1
5session.gc_probability=1
6session.gc_divisor=1
7session.gc_maxlifetime=0
8session.save_path=
9session.name=PHPSESSID
10session.save_handler=files
11--EXTENSIONS--
12session
13--SKIPIF--
14<?php include('skipif.inc'); ?>
15--FILE--
16<?php
17
18ob_start();
19
20function noisy_gc($maxlifetime) {
21    echo("GC [".$maxlifetime."]\n");
22    echo gc($maxlifetime)." deleted\n";
23    return true;
24}
25
26echo "*** Testing session_set_save_handler() : variation ***\n";
27
28require_once "save_handler.inc";
29$path = __DIR__ . '/session_set_save_handler_variation5';
30@mkdir($path);
31var_dump(session_save_path($path));
32
33echo "*** Without lazy_write ***\n";
34var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc", "create_sid", "validate_sid", "update"));
35var_dump(session_start(['lazy_write'=>FALSE]));
36$session_id = session_id();
37var_dump(session_id());
38var_dump(session_write_close());
39var_dump(session_id());
40
41echo "*** With lazy_write ***\n";
42var_dump(session_id($session_id));
43var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc", "create_sid", "validate_sid", "update"));
44var_dump(session_start(['lazy_write'=>TRUE]));
45var_dump(session_commit());
46var_dump(session_id());
47
48echo "*** Cleanup ***\n";
49var_dump(session_id($session_id));
50var_dump(session_start());
51var_dump(session_destroy());
52
53ob_end_flush();
54rmdir($path);
55?>
56--EXPECTF--
57*** Testing session_set_save_handler() : variation ***
58string(0) ""
59*** Without lazy_write ***
60bool(true)
61Open [%s,PHPSESSID]
62CreateID [PHPT-%d]
63Read [%s,PHPT-%d]
64GC [0]
651 deleted
66bool(true)
67string(%d) "PHPT-%d"
68Write [%s,PHPT-%d,]
69Close [%s,PHPSESSID]
70bool(true)
71string(%d) "PHPT-%d"
72*** With lazy_write ***
73string(%d) "PHPT-%d"
74bool(true)
75Open [%s,PHPSESSID]
76ValidateID [%s,PHPT-%d]
77Read [%s,PHPT-%d]
78GC [0]
791 deleted
80bool(true)
81Write [%s,PHPT-%d,]
82Close [%s,PHPSESSID]
83bool(true)
84string(%d) "PHPT-%d"
85*** Cleanup ***
86string(%d) "PHPT-%d"
87Open [%s,PHPSESSID]
88ValidateID [%s,PHPT-%d]
89Read [%s,PHPT-%d]
90GC [0]
911 deleted
92bool(true)
93Destroy [%s,PHPT-%d]
94
95Warning: unlink(%s): No such file or directory in %s on line %d
96Close [%s,PHPSESSID]
97bool(true)
98