Re: Problem with complex data structure and sessions
| From: | Zak Greant | Date: | Tue, 11 Dec 2001 02:59:28 +0000 |
| Subject: | Re: Problem with complex data structure and sessions | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-72995@lists.php.net to get a copy of this message | ||
Probably the best thing to do is visit http://bugs.php.net and
review
the guidelines for submitting a bug. If you get through the process
and feel that you have found a bug, please submit a bug report.
--zak
On December 10, 2001 02:51 pm, Frank wrote:
> 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?