Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68311 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66986 invoked from network); 25 Jul 2013 20:35:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2013 20:35:53 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:43248] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/B8-05798-52C81F15 for ; Thu, 25 Jul 2013 16:35:50 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 113E67000452; Thu, 25 Jul 2013 21:35:46 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id O6a8-ooFqFxG; Thu, 25 Jul 2013 21:35:44 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id A02CB700044F; Thu, 25 Jul 2013 21:35:44 +0100 (WEST) Received: from [IPv6:2001:981:8103:d8:96de:80ff:fe7e:525f] (unknown [IPv6:2001:981:8103:d8:96de:80ff:fe7e:525f]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 44FE3200CB42; Thu, 25 Jul 2013 21:35:44 +0100 (WEST) Message-ID: <51F18BEF.8000305@nebm.ist.utl.pt> Date: Thu, 25 Jul 2013 22:34:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20100101 Thunderbird/22.0 MIME-Version: 1.0 To: Jakub Zelenka , PHP internals list CC: nikic@php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] New handler for retrieving properties when object is serialized From: glopes@nebm.ist.utl.pt (Gustavo Lopes) 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