Re: [PHP4BETA] serialize() musings...

From: Date: Fri, 09 Apr 1999 19:36:17 +0000
Subject: Re: [PHP4BETA] serialize() musings...
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-63@lists.php.net to get a copy of this message
I really think we should get a bit more relaxed about serialzation stuff. The point of the php4 beta (at least from Andi's and my point of view) was to beta test the existing code, as well as move forward with implementing module generalization, thread safety and multiple server API support. Serialization isn't the first thing on our schedule. That said, I think you have a fundemental mistake in your entire approach to serialzation. Objects *never* serialize their methods. In PHP4, objects don't even really have methods, they belong to a class. When you want to serialize an object, you serialize its stateful data only, not its methods. Serializing the methods is a slow task that is pointless and wrong to do anyway. In a typical OO system, when you want to save an object, or transmit it over the network, you expect the other side (either yourself, or the machine you're sending the object to) to be able to recognize and handle that object. The machine on the other side will obtain the serialized data, find out what class it belongs to, instanciate an object of that class, and load the data to that object. Since we're not talking here about sending objects over the network, but usually, saving them in a database, identifying the object by its class name (and possibly, the ID of the current user) is more than enough. About references, these are usually serialized within the serialized object. It's true that a user can mess up if he creates an object with some circular dependencies or something like that, but you simply have to be bright enough to create serializable objects. Zeev At 14:09 09/04/99 +0200, Kristian Köhntopp wrote: > >1. NOT serializing slots > >Boris said that we do not absolutely need to be able to NOT >serialize() certain slots by kludging a wrapper with a static >member array: > >class C { > function wrap($varname, $value = "") { > static $store; > > if ($value != "") > $store[$varname] = $value; > > return $store[$varname]; > } >} > >I not not particularly like it. > > >2. references, loops and serialize() > >serialize() becomes quite ugly once you have references. >Basically, you need to have serialize() and deep_serialize() with >the latter being safe against self-referencing structures. > >Kristian > >-- >Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH >Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00 >Using PHP3? See our web development library at >http://phplib.shonline.de/ (GPL) > >-- >PHP 4 Beta > > > -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il -- PHP 4 Beta

« previous php.version4 (#63) next »