1--TEST--
2Test session_set_save_handler() : shutdown failure
3--INI--
4session.save_handler=files
5session.name=PHPSESSID
6--SKIPIF--
7<?php include('skipif.inc'); ?>
8--FILE--
9<?php
10
11ob_start();
12
13/*
14 * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true])
15 * Description : Sets user-level session storage functions
16 * Source code : ext/session/session.c
17 */
18
19echo "*** Testing session_set_save_handler() : shutdown failure ***\n";
20
21class MySession extends SessionHandler {
22	public $num;
23	public $destroyed = false;
24	public function __construct($num) {
25		$this->num = $num;
26		echo "(#$this->num) constructor called\n";
27	}
28	public function __destruct() {
29		echo "(#$this->num) destructor called\n";
30		$this->destroyed = true;
31	}
32	public function write($id, $data) {
33		if ($this->destroyed) {
34			echo "(#$this->num) destroyed, cannot write\n";
35		} else {
36			echo "(#$this->num) writing $id = $data\n";
37		}
38		return parent::write($id, $data);
39	}
40	public function close() {
41		$id = session_id();
42		if ($this->destroyed) {
43			echo "(#$this->num) destroyed, cannot write\n";
44		} else {
45			echo "(#$this->num) closing $id\n";
46		}
47		return parent::close();
48	}
49}
50
51$handler = new MySession(1);
52session_set_save_handler($handler, false);
53session_start();
54
55$_SESSION['foo'] = 'bar';
56
57echo "done\n";
58ob_end_flush();
59?>
60--EXPECT--
61*** Testing session_set_save_handler() : shutdown failure ***
62(#1) constructor called
63done
64(#1) destructor called
65(#1) destroyed, cannot write
66(#1) destroyed, cannot write
67