PHP 4.0 Bug #7412: assigning references from parts of array
| From: | panu dot kalliokoski at giro dot fi | Date: | Mon, 23 Oct 2000 15:54:24 +0000 |
| Subject: | PHP 4.0 Bug #7412: assigning references from parts of array | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-35963@lists.php.net to get a copy of this message | ||
From: panu.kalliokoski@giro.fi
Operating system: Debian GNU/Linux (potato)
PHP version: 4.0.3pl1
PHP Bug Type: *General Issues
Bug description: assigning references from parts of array
This is a problem where two features which I deem misfeatures together cause a greater problem. The
first misfeature is that, if I understand correctly, php destroys _every_ reference-style variable
when serialising them for session. Even turning them to normal and nice values would be better than
nothing - tracking serialised variables is not that hard, is it?
The first misfeature would not cause much harm if I could evade using references altogether.
However, in certain situations this is not the case. For example, if I have a deeply nested array
from which I have to find a cell, based on some data (and the level of nesting may vary) and then
assign a value to that cell, I have no choice but to use references because the $$ syntax does not
work for arrays. You'd think that only passing existing values as references would leave them
as values. But here comes the second misfeature. A clause such as
$arr = array( 'argh' );
$ref =& $arr[0];
actually turns $arr[0] into a reference.
There exists a workaround to this, which suggests that the misfeature could perhaps be corrected. It
turns out that if I pass $arr[0] as a reference to a _function_ or _method_, it doesn't turn
$arr[0] into a reference. So if I rewrite the loop that I use to dig into the array into a recursive
function, I can have my arrays not destroyed when serialised.
Even so, these two features are very irritating. Could they perhaps be corrected?
--
Edit Bug report at: http://bugs.php.net/?id=7412&edit=1