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