#32910 [Opn->Fbk]: session unset inside foreach breaks session write handler
| From: | sniper@php.net | Date: | Mon, 02 May 2005 11:40:13 +0000 |
| Subject: | #32910 [Opn->Fbk]: session unset inside foreach breaks session write handler | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78516@lists.php.net to get a copy of this message | ||
ID: 32910
Updated by: sniper@php.net
Reported By: bugs dot php dot net at enca dot cz
-Status: Open
+Status: Feedback
Bug Type: Session related
Operating System: MS Windows Server 2003
PHP Version: 5.0.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
Works fine for me..
Previous Comments:
------------------------------------------------------------------------
[2005-05-02 11:14:48] bugs dot php dot net at enca dot cz
Description:
------------
In this testcase the "write" function is not called. If you remove line
with "unset", the write function is called properly. If you delete whole
foreach cycle and use
"unset($_SESSION['A']);" instead, the "write" function si also called
-
as expected. This bug appear only when you call "unset" inside foreach
cycle.
My environment:
MS Windows Server 2003 SE (Windows NT 5.2 build 3790)
Apache/2.0.53 (Win32) PHP/5.0.4
Smilar (but not exactly same) bug is described as #32564, but it is in
the No feedback status and there is no way (for me) to change this
status. I hope that this "reproduce code" is much better then codes
from #32564
I can provide more information if you ask for them.
Reproduce code:
---------------
<?php
function foo(){return(true);}
function read($id){
return 'A|s:1:"a";B|s:1:"b";';
}
function write($id, $sess_data){
print "I'm writing this data: $sess_data\n";
return true;
}
header('Content-Type: text/plain');
session_set_save_handler("foo", "foo", "read", "write",
"foo", "foo");
session_start();
print_r($_SESSION);
foreach($_SESSION as $lsKey => $lsVal){
if($lsKey != 'A'){
unset($_SESSION[$lsKey]); //<<<<<<<< if you comment this line, the
write function is called properly
}
}
print_r($_SESSION);
?>
Expected result:
----------------
Array
(
[A] => a
[B] => b
)
Array
(
[A] => a
)
I'm writing this data: A|s:1:"a";
Actual result:
--------------
Array
(
[A] => a
[B] => b
)
Array
(
[A] => a
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32910&edit=1