xref: /PHP-5.4/ext/session/tests/bug32330.phpt (revision 21fb2a42)
1--TEST--
2Bug #32330 (session_destroy, "Failed to initialize storage module", custom session handler)
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--INI--
6session.use_trans_sid=0
7session.use_cookies=1
8session.name=sid
9session.save_path=/tmp
10session.gc_probability=1
11session.gc_divisor=1
12--FILE--
13<?php
14error_reporting(E_ALL);
15
16function sOpen($path, $name)
17{
18	echo "open: path = {$path}, name = {$name}\n";
19	return TRUE;
20}
21
22function sClose()
23{
24	echo "close\n";
25	return TRUE;
26}
27
28function sRead($id)
29{
30	echo "read: id = {$id}\n";
31	return '';
32}
33
34function sWrite($id, $data)
35{
36	echo "write: id = {$id}, data = {$data}\n";
37	return TRUE;
38}
39
40function sDestroy($id)
41{
42	echo "destroy: id = {$id}\n";
43	return TRUE;
44}
45
46function sGC($maxlifetime)
47{
48	echo "gc: maxlifetime = {$maxlifetime}\n";
49	return TRUE;
50}
51
52session_set_save_handler( 'sOpen', 'sClose', 'sRead', 'sWrite', 'sDestroy', 'sGC' );
53
54// without output buffering, the debug messages will cause all manner of warnings
55ob_start();
56
57session_start();
58$_SESSION['A'] = 'B';
59session_write_close();
60
61session_start();
62$_SESSION['C'] = 'D';
63session_destroy();
64
65session_start();
66$_SESSION['E'] = 'F';
67// Don't try to destroy this time!
68
69?>
70--EXPECTF--
71open: path = /tmp, name = sid
72read: id = %s
73gc: maxlifetime = %d
74write: id = %s, data = A|s:1:"B";
75close
76open: path = /tmp, name = sid
77read: id = %s
78gc: maxlifetime = %d
79destroy: id = %s
80close
81open: path = /tmp, name = sid
82read: id = %s
83gc: maxlifetime = %d
84write: id = %s, data = E|s:1:"F";
85close
86