From: luca dot fabbro at procne dot it
Operating system: Linux
PHP version: 4.3.10
PHP Bug Type: Session related
Bug description: Pointer to item in $_SESSION superglobal causes troubles
Description:
------------
Seems that once you've declared a pointer to one of the items in session
superglobal any other assignment of a variable to that session item is
alwayys treated as a pointer.
Tested on various versions of php 4.3 till 4.3.1
Register globals are OFF
php 5.0.4 having same error
Reproduce code:
---------------
session_start();
for ($i = 0; $i < 2; $i++)
{
$_SESSION['storage'][$i] = array('items'=>$i);
}
$items = count($_SESSION['storage']);
for ($i = 0; $i < $items; $i++)
{
$pointer = &$_SESSION['storage'][$i];
// unset($pointer); // Uncomment me to let me work properly
}
$gitems = $_SESSION['storage'];
foreach ($gitems as $key=>$val)
{
$gitems[$key]['foo'] = time();
}
Expected result:
----------------
$_SESSION = Array
(
[storage] => Array
(
[0] => Array
(
[items] => 0
)
[1] => Array
(
[items] => 1
)
)
)
Actual result:
--------------
$_SESSION = Array
(
[storage] => Array
(
[0] => Array
(
[items] => 0
[foo] => 1118913576
)
[1] => Array
(
[items] => 1
[foo] => 1118913576
)
)
)
--
Edit bug report at http://bugs.php.net/?id=33360&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33360&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33360&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33360&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33360&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33360&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33360&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33360&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33360&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33360&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33360&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33360&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33360&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33360&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33360&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33360&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33360&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33360&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33360&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33360&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33360&r=mysqlcfg