Re: Return value of get_properties handler
| From: | Christoph M. Becker | Date: | Tue, 20 Nov 2018 23:33:41 +0000 |
| Subject: | Re: Return value of get_properties handler | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103467@lists.php.net to get a copy of this message | ||
Also forwarding to the list.
On 20.11.2018 at 11:50, Nikita Popov wrote:
> On Tue, Nov 20, 2018 at 11:44 AM Christoph M. Becker <cmbecker69@gmx.de>
> wrote:
>
>> With regard to bug #77177[1], I'm wondering whether a get_properties
>> handler[2] is allowed to return NULL, or whether an empty hash table has
>> to be returned instead.
>>
>> [1] <https://bugs.php.net/bug.php?id=77177>
>> [2]
>> <https://github.com/php/php-src/blob/php-7.3.0RC5/Zend/zend_object_handlers.h#L91-L92Õ¾ˆÕ§ÂÒ4
>> [Ò)lÎU>
>
> It's currently considered legal, but I would like to move towards not
> allowing it (I've already tightened up requirements for many other object
> handlers in master). A NULL return value from get_properties can be
> replaced by a return of &zend_empty_array, which saves all the consuming
> code from having to perform unnecessary null checks. I would recommend
> changing that code to return &zend_empty_array, rather than make
> serialization check NULL.
>
> Additionally, COM should really be setting the
> serialize_deny/unserialize_deny handlers, to explicitly prohibit
> serialization, rather than just return a garbage value.
Thanks, Nikita! I've just opened
<https://github.com/php/php-src/pull/3672>.
--
Christoph M. Becker