[nycphp-talk] Incomplete Objects, Class Definitions and require_once
lists at enobrev.com
Thu Aug 9 09:01:30 EDT 2007
Michael B Allen wrote:
>> Well I figured out what the problem was. I was putting an 'Auth'
>> object in the session. I made some changes to something that
>> invalidated the class definition of that object. As soon as I logged
>> out the Auth object in the session was reinstantiated and the error
>> went away. No big deal.
> It seems you must require_once the class of the object stored in the session before
> calling session_start. I guess session_start is deserializing things
> and if the class definition isn't available it defaults to an
> incomplete type.
The problem has to do with serializing/unserializing objects (which
sessions do in the background).
When you serialize an entire class, it only saves the classes
properties, not the methods within. (open up a serialized object file to
see what i mean). When you unserialize it, you'll be creating a
variable with all the properties of a class. If you've defined that
class (in your case, by requiring the class file before unserializing
it), it will instantiate the class and fill in the proper properties and
then put it into your variable. Otherwise it will create an
'incomplete' class that only has the same name and all the saved
properties, but no methods.
Here's some other info on the subject as well
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the talk