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:17:32 +0000
Subject: Re: PHP 4.0 Bug #5152: Object passed in a session generates errors when member functions are called
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-21914@lists.php.net to get a copy of this message
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.... -Szii

« previous php.dev (#21914) next »