|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-09 00:32 UTC] haliferi at freemail dot hu
Description:
------------
I am running PHP 5.3.10 x86 (API220090626,NTS,VC9) on IIS7.5 with Wincache Version 1.1.0630.0, opcode cache enabled, session works in all other cases.
I have an array in the session, but if i unset the first item, and add a new to the and, then Wincache won't save it to the session in my case. But if i modify the item count: unset the first 2 element, then it will be saved. The other session variables are not affected, objects, ints are successfully saved to the session.
I tested it with WinCache 1.2.427, 1.2.614 and 1.2.1208 too, but nothing changed.
Test script:
---------------
$_SESSION['chresp'] = array( // already saved in the session
'dfjkg6' =>
array('a' => 'gdfg7df887', 'b' => 'h34g3436sh', 'valid' => 1331196464),
'5gf5av' =>
array('a' => 'tu4dcff3d3', 'b' => 'gh323fghd3', 'valid' => 1331196465),
's7g35b' =>
array('a' => '32a4djg2sa', 'b' => 'ib78m37fdj', 'valid' => 1331196466));
if (count($_SESSION['chresp']) > 2)
array_shift($_SESSION['chresp']);
$_SESSION['chresp']['kjhg7f'] =
array('a' => 'kgkj3dfkg7', 'b' => 'as88f4jk4jk', 'valid' => 1331196467);
// i can see the new value here, but the next refresh the init array appears again
Expected result:
----------------
The new array has saved to the session.
Actual result:
--------------
If i run the test script standalone, it works, but as i run it in my project, it produces the bug, maybe another session, or wincache user cache reads/writes have makes this effect together.
But if i switch to any other session handler in the php.ini (memcache, simple file), it solves the problem.
The most weird is that modifying the element count makes Wincache to save it.
There is no error, warning, everything is in order, just the array won't be updated in the wincache session store.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Mar 10 12:00:01 2026 UTC |
I wrote a script to simulate this issue with the session array and tested it with PHP7 + WinCache 2.0.0.0 on x64. I was unable to repro the issue. Test Script: ------------ <?php function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } session_start(); $sess_data = $_SESSION['chresp']; if (NULL == $sess_data) { $sess_data = array( 'dfjkg6' => array('a' => 'gdfg7df887', 'b' => 'h34g3436sh', 'valid' => 1331196464), '5gf5av' => array('a' => 'tu4dcff3d3', 'b' => 'gh323fghd3', 'valid' => 1331196465), 's7g35b' => array('a' => '32a4djg2sa', 'b' => 'ib78m37fdj', 'valid' => 1331196466)); echo("Original array \$sess_data:\n"); var_dump($sess_data); $_SESSION['chresp'] = $sess_data; } else { echo("Session 'chresp' already exists!\n"); } echo("fetched from \$_SESSION['chresp']\n"); var_dump($_SESSION['chresp']); if (count($_SESSION['chresp']) > 2) array_shift($_SESSION['chresp']); $new_element = generateRandomString(6); $_SESSION['chresp'][$new_element] = array('a' => generateRandomString(), 'b' => generateRandomString(), 'valid' => 1331196467); echo("fetched from \$_SESSION['chresp'] after array_shift'ing and adding new element $new_element\n"); var_dump($_SESSION['chresp']); ?>