Re: New handler for retrieving properties when object is serialized

From: Date: Thu, 25 Jul 2013 20:34:55 +0000
Subject: Re: New handler for retrieving properties when object is serialized
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 25-07-2013 18:42, Jakub Zelenka wrote:
I have just sent this PR: https://github.com/php/php-src/pull/397 It's reaction to the comment from nikic in PR: https://github.com/php/php-src/pull/393 The patch is about adding new object handler that is used when object is serialized. Currently this needs to be done using get_properties which is sometimes a bit over kill. It's useful in situation if you only need to change properties for serialization. It's very similar to get_debug_info that is used only in specific situations (print_r...)
This seems too narrow a situation to warrant a new serialization method, in addition to the two we already have. That said, there are two precedents: * get_debug_info (variant for var_dump) * get_gc (variant for garbage collection) And anyway, if you really want to add special properties for serialization, you can use the same hack that was used before get_gc was available: http://lxr.php.net/xref/PHP_5_3/ext/spl/spl_observer.c#297 (and http://lxr.php.net/xref/PHP_5_3/ext/spl/spl_observer.c#258 ) You can check for BG(serialize_lock) instead of GC_G(gc_active) What I think is that we should add an extra parameter to get_properties instead of keeping adding these. -- Gustavo Lopes

Thread (22 messages)

« previous php.internals (#68311) next »