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