Problem with complex data structure and sessions
| From: | Frank | Date: | Mon, 10 Dec 2001 21:51:43 +0000 |
| Subject: | Problem with complex data structure and sessions | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-72989@lists.php.net to get a copy of this message | ||
I am new to online PHP communities so if there is a better place to post
this please let me know.
I may have encountered a bug in PHP 4.0.6, but I don't know where to look to
see if it is a known problem, and I have not been able to reproduce the
problem in trivial code.
I have been programming for a couple decades now, but just started with PHP
a few months ago. I've spent a couple months developing a fairly typical
catalog / shopping cart / order system for a small web site. My code works
flawlessly on 4.0.8 under Windows XP (my development environment), but when
I uploaded it to our host (4.0.6 under FreeBSD) it failed in the following
way:
The Shopping cart (we call it a basket) object includes a two dimensional
array of "item" objects indexed by catalog number and package size, and a
second array of references to the same item objects. Simplified a little,
items are added like this:
$this->items[$catalognum][$size] = new BasketItem($catalognum, $size,
$quantity);
$this->ref[] = &$this->items[$catalognum][$size];
Somewhere in the serialize/store/load/unserialize process handled by the
built in session support, $basket->ref[] comes to contain references to
arrays rather than references to objects. If I add an "echo
$basket->ref[0]" line to a particular page it will print "Object" on the hit
that creates the basket, and "Array" when I refresh the page. Under
4.0.8/Windows it will print "Object" each time.
This problem causes my code to fail with a "Call to a member function on a
non-object" error.
Where can I best look to see if this is a known problem?
Frank.
-----
The very act of seeking sets something in motion to meet us;
something in the universe, or in the unconscious responds as if
to an invitation. - Jean Shinoda Bolen