php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7412 assigning references from parts of array
Submitted: 2000-10-23 11:54 UTC Modified: 2000-10-30 09:41 UTC
From: panu dot kalliokoski at giro dot fi Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.3pl1 OS: Debian GNU/Linux (potato)
Private report: No CVE-ID: None
 [2000-10-23 11:54 UTC] panu dot kalliokoski at giro dot fi
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?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-30 09:41 UTC] stas@php.net
I see no bug here. Please read the "references explained" part in the manual.

As for serializing references - patch is under way. Expect it in next PHP version or in CVS in coming days.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC