Bug #73343 [NEW]: extra call to read in session_regenerate_id in custom session handler

From: Date: Tue, 18 Oct 2016 23:51:57 +0000
Subject: Bug #73343 [NEW]: extra call to read in session_regenerate_id in custom session handler
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204904@lists.php.net to get a copy of this message
From: ryan dot brothers at gmail dot com Operating system: Linux PHP version: 7.1.0RC3 Package: Session related Bug Type: Bug Bug description:extra call to read in session_regenerate_id in custom session handler Description: ------------ When using a custom session handler in PHP 7 or 7.1, when session_regenerate_id() is called, the read function is called on the new session_id. This does not occur in PHP 5.6. This extra call to read is causing an issue in my custom session handler. From my testing, it appears to ignore the result of the read call anyway as in the below, abc remains 1. Is there a reason for this extra call to read? Thanks for your help. Test script: --------------- <?php class test_session_handler implements SessionHandlerInterface { public function open($save_path, $session_name) { return true; } public function close() { return true; } public function read($id) { if ($GLOBALS['in_session_regenerate_id'] == true) { echo 'read in session_regenerate_id<br>'; return 'abc|i:2;'; } else { echo 'read<br>'; return 'abc|i:1;'; } } public function write($session_id, $session_data) { return true; } public function destroy($session_id) { return true; } public function gc($maxlifetime) { return true; } } ob_start(); $GLOBALS['in_session_regenerate_id'] = false; session_set_save_handler(new test_session_handler()); session_start(); echo 'start session_regenerate_id<br>'; $GLOBALS['in_session_regenerate_id'] = true; session_regenerate_id(true); echo 'end session_regenerate_id<br>'; echo $_SESSION['abc']; Expected result: ---------------- read start session_regenerate_id end session_regenerate_id 1 Actual result: -------------- read start session_regenerate_id read in session_regenerate_id end session_regenerate_id 1 -- Edit bug report at https://bugs.php.net/bug.php?id=73343&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73343&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73343&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73343&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73343&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73343&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73343&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73343&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73343&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73343&r=support Expected behavior: https://bugs.php.net/fix.php?id=73343&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73343&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73343&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73343&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73343&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73343&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73343&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73343&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73343&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73343&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73343&r=mysqlcfg

« previous php.bugs (#204904) next »