session containing nested classes becomes null on function access (PHP < 4.1.0)

From: Date: Wed, 07 Aug 2002 13:56:38 +0000
Subject: session containing nested classes becomes null on function access (PHP < 4.1.0)
Groups: php.general 
Request: Send a blank email to php-general+get-111504@lists.php.net to get a copy of this message
This post is mostly to help others who may have stumbled acorss this bug (which I have today discovered has been fixed in newer versions of php by testing it myself) as I could not find any reference to it from an intensive search on both the main mailing list and the bugs.php.net site. The bug occured for me on our production server running PHP 4.0.3pl1 but was not a problem on PHP 4.2.2. I assume that the bug was probably fixed when the $_SESSION style of session handling was introduced. I have reduced it down to a test case for the sake of simplicity and reproduceability. Two versions of the code are attached, one for pre 4.1.0 (test.php) and one for PHP >= 4.1.0 (test_php4.php). For pre 4.1.0, as soon as $MainClass->MainMemberClass[$index]->bar() is called, all of the member objects of the MainClass object in the session are nulled out. I store the MainClass object in a session, and everything carries from page to page just fine except for when I try to access a (public) member function of type MainMemberClass from within MainClass. If you run the test.php script on pre 4.1.0 and follow the link it will null out the member objects as I describe. The rest of the object information remains intact. All of the class definitions are the first thing in the file so it is not an issue with the session starting before the class definition. The problem does not occur when using the test_php4.php script on PHP >= 4.1.0. Not really sure why the test.php script won't work on post 4.1.0 since I think you can still use session_register instead of setting stuff directly in $_SESSION. In any event.. hope this helps others avoid the major debug time it took me to figure this out... -- ---------------------------------- Marc Swanson, Software Engineer Sonitrol Communications Corp. Hartford, CT Email: mswanson@sonitrol.net Phone: (860) 616-7036 Pager: (860) 948-6713 Cell: (603) 512-1267 Fax: (860) 616-7589 ----------------------------------

Attachment: [text/x-c++src] test.php
Attachment: [text/x-c++src] test_php4.php
« previous php.general (#111504) next »