DataObject connect problem using sessions

From: Date: Wed, 04 Dec 2002 23:42:24 +0000
Subject: DataObject connect problem using sessions
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2895@lists.php.net to get a copy of this message
I'm faced with a rather odd bug for which I think I've figured out the cause, yet can't really think of a good solution. The context where I originally found it is a bit different that what I describe here, but I wrote some simple code to help narrow down the problem. Consider the following code: //sessiontest1.php //---------------- include('myinclude.inc.php'); session_start(); if(!session_is_registered("testuser")) session_register("testuser"); $testuser = new DataObjects_User; $testuser->get('user_id', 1); $testuser->active = 0; $testuser->update(); //---------------- That code works perfectly, and the update goes off without a hitch. Everything seems fine, however, in the next document, I try to used the $testuser object which was stored in the session... //sessiontest2.php //---------------- include("myinclude.inc.php"); session_start(); print_r($testuser); $testuser->active = 1; $testuser->update(); //---------------- This *should* work, but instead, I get this error: "Fatal error: Call to a member function on a non-object in DataObject.php on line 1022" The contents of that line are: $results[$this->_DB_resultid] = $__DB->query($string); so, further investigation revealed that $__DB was in fact NULL, as were the $connections and $results variables set at the top of the function. so, it appears as though calls to PEAR::getStaticProperty are returning NULL values for some reason, though I've got no idea why. If I create a new object of the same class (User) and use setFrom(), then attempt to update, it works just fine. This issue only comes up on objects which were created in other scripts, then stored in sessions. I'd really like to figure out why this is happening, because as you can imagine, it potentially affects a lot of functionality across my application. Thanks very much in advance for any help! Leigh Caplan maelman@u.washington.edu

« previous php.pear.general (#2895) next »