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 ***
61
62Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
63bool(true)
64Open [%s,PHPSESSID]
65CreateID [PHPT-%d]
66Read [%s,PHPT-%d]
67GC [0]
681 deleted
69bool(true)
70string(%d) "PHPT-%d"
71Write [%s,PHPT-%d,]
72Close [%s,PHPSESSID]
73bool(true)
74string(%d) "PHPT-%d"
75*** With lazy_write ***
76string(%d) "PHPT-%d"
77
78Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
79bool(true)
80Open [%s,PHPSESSID]
81ValidateID [%s,PHPT-%d]
82Read [%s,PHPT-%d]
83GC [0]
841 deleted
85bool(true)
86Write [%s,PHPT-%d,]
87Close [%s,PHPSESSID]
88bool(true)
89string(%d) "PHPT-%d"
90*** Cleanup ***
91string(%d) "PHPT-%d"
92Open [%s,PHPSESSID]
93ValidateID [%s,PHPT-%d]
94Read [%s,PHPT-%d]
95GC [0]
961 deleted
97bool(true)
98Destroy [%s,PHPT-%d]
99
100Warning: unlink(%s): No such file or directory in %s on line %d
101Close [%s,PHPSESSID]
102bool(true)
103