1--TEST--
2Test session_set_save_handler() : incorrect arguments for existing handler open
3--INI--
4session.save_handler=files
5session.name=PHPSESSID
6session.gc_probability=0
7--EXTENSIONS--
8session
9--SKIPIF--
10<?php include('skipif.inc'); ?>
11--FILE--
12<?php
13
14ob_start();
15
16echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***\n";
17
18class MySession extends SessionHandler {
19    public $i = 0;
20    public function open($path, $name): bool {
21        ++$this->i;
22        echo 'Open ', session_id(), "\n";
23        // This test was written for broken return value handling
24        // Mimmick what was actually being tested by returning true here
25        return (null === parent::open());
26    }
27    public function read($key): string|false {
28        ++$this->i;
29        echo 'Read ', session_id(), "\n";
30        return parent::read($key);
31    }
32}
33
34$oldHandler = ini_get('session.save_handler');
35$handler = new MySession;
36session_set_save_handler($handler);
37try {
38    var_dump(session_start());
39} catch (TypeError $e) {
40    echo $e->getMessage(), "\n";
41}
42
43var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION);
44?>
45--EXPECTF--
46*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***
47Open
48SessionHandler::open() expects exactly 2 arguments, 0 given
49
50Warning: Undefined global variable $_SESSION in %s on line %d
51string(0) ""
52string(5) "files"
53string(4) "user"
54int(1)
55NULL
56