php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #16387 PHP loop when using reference to an object in an object (both in session)
Submitted: 2002-04-02 05:29 UTC Modified: 2005-12-16 15:58 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: caugustin at alcyonis dot fr Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: ANY
Private report: No CVE-ID: None
 [2002-04-02 05:29 UTC] caugustin at alcyonis dot fr
Hello, I don't know if it is really a bug, but it display nothing in error log and it is very anoying.

I create an object 'order' and an object 'customer'. The order object has a customer object inside. To avoid duplicate in session I tried the following code when the customer login and have already started to order:

$current_order->customer = &$current_customer;

After this, PHP display the current page well, but any next page fail to display. Nothing apear in error_log. On a personal log system I can see that PHP is starting to loop on the page juste after the session is initialized and when the line

session_register('current_customer');

is called. PHP hang after about 20 loops.

After reading in detail the way session are working, I understand better that my code is a little bit dangerous (use reference in session), but PHP should return an error or display anything when it face this king of code and not enter in an invisible loop.

Cedric.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-02 05:47 UTC] yohgaki@php.net
It's known issue.
Reference does not work well with session variable...

 [2002-04-02 08:41 UTC] yohgaki@php.net
I'll make this a documentation problem for now.
Even if we made PHP not to crash with reference, there is no feasible way to restore reference to other variable. 

If anyone documented the issue, please change category back to Session Related and keep this report open. PHP should warn if user uses reference in session vars.
 [2004-06-06 15:59 UTC] dvck0 at galaxienet dot cz
i have same problem with store object with references
i register $Session

$Session->Modules->Module->Modules = &$Session->Modules;

firsttime not loop, but if session restore object, make 6-12 loop, php not tell me, i find this if store data to DB and 1 record is stored 6-12times, this is bad for PHP, i like programing with class, i must rewrite all code :((
 [2004-08-06 23:52 UTC] vrana@php.net
Warning added to manual: "You can't use references in session variables as there is no feasible way to restore reference to other variable."

Leaving open and reclasified at request of yohgaki.
 [2004-12-01 19:13 UTC] tony2001@php.net
Seems to be fixed a long time ago.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC