Re: [PHP4BETA] Re: SESS: objects containing objects *final statement*(?) please read!

From: Date: Fri, 25 Feb 2000 15:36:31 +0000
Subject: Re: [PHP4BETA] Re: SESS: objects containing objects *final statement*(?) please read!
References: 1 2 3 4  Groups: php.version4 
Request: Send a blank email to php-version4+get-10954@lists.php.net to get a copy of this message
On Fri, Feb 25, 2000 at 09:27:31AM -0600, Andrei Zmievski wrote: > On Fri, 25 Feb 2000, Stig Bakken wrote: > > It would be more clear to have two functions: get_class_vars() and > > get_object_vars(), to make sure people don't mix up classes and their > > instances. > > That's fine. > > > As long as the values are references, I don't see any harm in including > > them. > > I'd say they should just increment the refcount and return the value, > not use the actual reference (it'd be bad if you changed the value and > the class var value would also change). > > > Now, when it comes to waking up unserialized objects again, calling the > > constructor is definitely not what we want. If the constructor > > initializes member variables, which they often do, it is plain wrong. > > There should probably be a method called before serialization and one > > after unserialization. There are three ways of doing this: fixed method > > names like "beforeSerialize" and "afterUnserialize", method names > > based > > on the class name like "MyClass_beforeSerialize" and > > "MyClass_afterUnserialize", or having functions to register which method > > in your class should be used. Example: > > > > class MyDBClass { > > var $dbh; > > function MyClass($dsn) { > > register_object_serialize_method($this, "prepareForSerialize"); > > register_object_unserialize_method($this, > > "wakeupAfterUnserialize"); > > $this->dbh = DB::connect($dsn); > > } > > function prepareForSerialize() { > > if ($this->dbh) { > > $this->dbh_info = $dbh->getDSN(); > > $dbh->disconnect(); > > } > > } > > function wakeupAfterUnserialize() { > > if ($this->dbh_info) { > > $this->dbh = DB::connect($this->dbh_info); > > unset($this->dbh_info); > > } > > } > > } > > Would register_object_serialize_method() use some global table where it > registers class name and these methods? c'mon boys we can do nicer that this? i really like the sleep()/wakeup() thing - but shouldn't we make some standard method names part of the language instead of having to register_blabla_() them. i don't see why somebody would have to name them different. BTW: what about not serializing class variables that start with a '_' character. the usage should be obvious, right? > > -Andrei > > "The time from now until the completion > of the project tends to become constant." -- Douglas Hartree > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-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.version4 (#10954) next »