Re: PHP 4.0 Bug #5152: Object passed in a session generates errors when member functions are called

From: Date: Wed, 21 Jun 2000 16:43:15 +0000
Subject: Re: PHP 4.0 Bug #5152: Object passed in a session generates errors when member functions are called
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-21916@lists.php.net to get a copy of this message
On Wed, Jun 21, 2000 at 09:17:32AM -0700, Szii wrote: > At 11:10 AM 6/21/00 +0300, Stanislav Malyshev wrote: > >S>> It is, unfortunately, a known problem. > > > >I still don't see why is it the problem. You should define your classes > >before you are tryinh to use them (even in sessions). Using require would > >solve problems with that example. > > > > No, it is not. Please stop spreading FUD. > > > > - Sascha > > > Instantiate a class. session_register() it. Go to another page. > > 1) For every single damn page you go to, you MUST have included > the header file, or session_start() will complain. This is true even > for pages that DON'T USE THAT CLASS AT ALL. So if you reg a > class in a page, you must include it for EVERY PAGE ON YOUR > SITE that uses session_start(). For 1 user object, this may be > acceptable but won't scale. > > 2) You can't just require() it ahead of time. I've tried require() and > include() and neither one works. It just complains about std_class. > If I put require()/include() AFTER session_start() then they are > auto-loaded but without methods. > > When the deserialize method is called, IMHO, it should NOT > even ATTEMPT to autoload a class. You should call > $myvar = session_load_class("my_class") to pull it out. This method > does not currently exist, but I'm looking at adding it. > > That route fixes the std_class problem, the "no methods" problem, > and you won't have to include the header files (if you have 40 classes > it could be a problem) on pages that don't even USE the classes. Not > only is it smoother, but you're not autoloading everything that you're > not using and therefore don't take the performance hit for it. > > Got a better way? Love to hear it.... even though i don't like the language you've choosen and besides the fact that objects _do_ work in sessions - as long as you do follow the rules (which everybody besides you seem to be able to) +plus+ looking at the fact that you seem to not even have looked at how the serialize/deserialize mechanisms of state data work in php (so it's rather unlikely that you're going to offer any kind of solution to this anywhen in the near future) +plus+ beeing sick of this... +plus+ (in the end) understanding that you have a valid point in saying that loosing the object-class relation in a page that does not include the needed class code is a "suboptimal" thing. i've concluded to change the "Unserializing non-existant class ..." warning (plus the needed code) to create an empty class with the "right" name so that the serialized object will keep is association to the class and will be fully working again on the next page that has the code for the class available. that should make you happy and stop moaning and spreading FUD. thank you tc > > -Szii > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.dev (#21916) next »