Re: PHP 7.0.3 RC1 is available for testing - **** BC break ***
| From: | Remi Collet | Date: | Fri, 22 Jan 2016 12:15:36 +0000 |
| Subject: | Re: PHP 7.0.3 RC1 is available for testing - **** BC break *** | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-90829@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 22/01/2016 11:38, Remi Collet a écrit :
> Reproducer attached
>
> It seems that using a user land SessionHandler, the "write" method
> is not called, raising this issue.
Attached as .phpt
Notice: the issue only happens after the:
PHP Warning: session_start(): Cannot send session cookie - headers
already sent by ...
Remove the "Start" at the beginning and the test pass with 5.6.18RC1
Remi.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlaiHWYACgkQYUppBSnxahi1GQCgsaUt2tS20DH9Rd0+AkIwHqIC
ErgAn2dJZ4pR0gWcCABj5EBbRECjGnsu
=QB2l
-----END PGP SIGNATURE-----
--TEST-- Testing repated SessionHandler::open() calls --SKIPIF-- <?php //include('skipif.inc'); ?> --FILE-- Start <?php class MySessionHandler implements SessionHandlerInterface { private $tab; private $dbg; public function __construct () { $this->tab = array(); $this->dbg = array(); } public function close () { $this->dbg[] = __METHOD__ . "()"; return true; } public function destroy ($session_id) { $this->dbg[] = __METHOD__ . "('$session_id')"; unset($this->tab[$session_id]); return true; } public function gc ($maxlifetime) { $this->dbg[] = __METHOD__ . "('$maxlifetime')"; return true; } public function open ($save_path, $name) { $this->dbg[] = __METHOD__ . "('$save_path', '$name')"; return true; } public function read($session_id) { if (isset($this->tab[$session_id])) { $this->dbg[] = __METHOD__ . "('$session_id') => '" . $this->tab[$session_id] . "'"; return $this->tab[$session_id]; } $this->dbg[] = __METHOD__ . "('$session_id') => not found"; return ''; } public function write ($session_id, $session_data) { $this->dbg[] = __METHOD__ . "('$session_id', '$session_data')"; $this->tab[$session_id] = $session_data; return true; } public function trace() { print_r($this->dbg); } } ini_set('session.save_path', '/tmp'); $handler = new MySessionHandler(); session_set_save_handler($handler, true); // Write session_name('sessionname'); session_id('sessionid'); session_start(); $_SESSION['sessiondata'] = 'foo'; session_write_close(); // Reopen session_name('sessionname'); session_id('sessionid'); session_start(); session_write_close(); $handler->trace(); ?> Done --EXPECTF-- Start Warning: session_start(): Cannot send session cookie - headers already sent %s Warning: session_start(): Cannot send session cache limiter - headers already sent %s Warning: session_start(): Cannot send session cookie - headers already sent %s Warning: session_start(): Cannot send session cache limiter - headers already sent %s Array ( [0] => MySessionHandler::open('/tmp', 'sessionname') [1] => MySessionHandler::read('sessionid') => not found [2] => MySessionHandler::write('sessionid', 'sessiondata|s:3:"foo";') [3] => MySessionHandler::close() [4] => MySessionHandler::open('/tmp', 'sessionname') [5] => MySessionHandler::read('sessionid') => 'sessiondata|s:3:"foo";' [6] => MySessionHandler::write('sessionid', 'sessiondata|s:3:"foo";') [7] => MySessionHandler::close() ) Done
--TEST-- Testing repated SessionHandler::open() calls --SKIPIF-- <?php //include('skipif.inc'); ?> --FILE-- Start <?php class MySessionHandler implements SessionHandlerInterface { private $tab; private $dbg; public function __construct () { $this->tab = array(); $this->dbg = array(); } public function close () { $this->dbg[] = __METHOD__ . "()"; return true; } public function destroy ($session_id) { $this->dbg[] = __METHOD__ . "('$session_id')"; unset($this->tab[$session_id]); return true; } public function gc ($maxlifetime) { $this->dbg[] = __METHOD__ . "('$maxlifetime')"; return true; } public function open ($save_path, $name) { $this->dbg[] = __METHOD__ . "('$save_path', '$name')"; return true; } public function read($session_id) { if (isset($this->tab[$session_id])) { $this->dbg[] = __METHOD__ . "('$session_id') => '" . $this->tab[$session_id] . "'"; return $this->tab[$session_id]; } $this->dbg[] = __METHOD__ . "('$session_id') => not found"; return ''; } public function write ($session_id, $session_data) { $this->dbg[] = __METHOD__ . "('$session_id', '$session_data')"; $this->tab[$session_id] = $session_data; return true; } public function trace() { print_r($this->dbg); } } ini_set('session.save_path', '/tmp'); $handler = new MySessionHandler(); session_set_save_handler($handler, true); // Write session_name('sessionname'); session_id('sessionid'); session_start(); $_SESSION['sessiondata'] = 'foo'; session_write_close(); // Reopen session_name('sessionname'); session_id('sessionid'); session_start(); session_write_close(); $handler->trace(); ?> Done --EXPECTF-- Start Warning: session_start(): Cannot send session cookie - headers already sent %s Warning: session_start(): Cannot send session cache limiter - headers already sent %s Warning: session_start(): Cannot send session cookie - headers already sent %s Warning: session_start(): Cannot send session cache limiter - headers already sent %s Array ( [0] => MySessionHandler::open('/tmp', 'sessionname') [1] => MySessionHandler::read('sessionid') => not found [2] => MySessionHandler::write('sessionid', 'sessiondata|s:3:"foo";') [3] => MySessionHandler::close() [4] => MySessionHandler::open('/tmp', 'sessionname') [5] => MySessionHandler::read('sessionid') => 'sessiondata|s:3:"foo";' [6] => MySessionHandler::write('sessionid', 'sessiondata|s:3:"foo";') [7] => MySessionHandler::close() ) Done