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