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--SKIPIF-- 8<?php include('skipif.inc'); ?> 9--FILE-- 10<?php 11 12ob_start(); 13 14/* 15 * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) 16 * Description : Sets user-level session storage functions 17 * Source code : ext/session/session.c 18 */ 19 20echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***\n"; 21 22class MySession extends SessionHandler { 23 public $i = 0; 24 public function open($path, $name) { 25 ++$this->i; 26 echo 'Open ', session_id(), "\n"; 27 // This test was written for broken return value handling 28 // Mimmick what was actually being tested by returning true here 29 return (null === parent::open()); 30 } 31 public function read($key) { 32 ++$this->i; 33 echo 'Read ', session_id(), "\n"; 34 return parent::read($key); 35 } 36} 37 38$oldHandler = ini_get('session.save_handler'); 39$handler = new MySession; 40session_set_save_handler($handler); 41session_start(); 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 48 49Warning: SessionHandler::open() expects exactly 2 parameters, 0 given in %s on line %d 50Read %s 51 52Warning: SessionHandler::read(): Parent session handler is not open in %s on line %d 53string(%d) "%s" 54string(5) "files" 55string(4) "user" 56int(2) 57array(0) { 58} 59 60Warning: SessionHandler::write(): Parent session handler is not open in Unknown on line 0 61 62Warning: session_write_close(): Failed to write session data %s in %s on line %d 63 64Warning: SessionHandler::close(): Parent session handler is not open in Unknown on line 0 65