#40477 [Bgs]: object's read property handler not used in zend_print_zval_r_ex
| From: | piotrek dot pokora at gmail dot com | Date: | Wed, 14 Feb 2007 14:49:57 +0000 |
| Subject: | #40477 [Bgs]: object's read property handler not used in zend_print_zval_r_ex | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108878@lists.php.net to get a copy of this message | ||
ID: 40477
User updated by: piotrek dot pokora at gmail dot com
Reported By: piotrek dot pokora at gmail dot com
Status: Bogus
Bug Type: Variables related
Operating System: debian/linux
PHP Version: 5.2.1
New Comment:
>Of course get_properties() is required, how else do you >think it
should work?
As it works without get_properties.
It's enough to add own read and write property hook and some function
which "registers" properties of an object in constructor.
It works _perfect_ for reading property, assigning value to it. And the
same for derived classes.
Look at mysqli implementation.
It DOES NOT contain get_properties hook and works. Why?
>You need to know the name of the property to be able to call
>read_property().
Hook function requires zval *member as second argument.
I do not know internals , please tell me :)
read_property hook works _perfect_ without get_properties hook.
>The fact that you can't find any docs for >get_properties()(which is
>implemented quite a number of times in PHP sources) is >hardly a PHP
bug.
Yes, but the logic bug here is the fact that always internal zend
functions "operate" in object's handlers with this little exception of
print_t or var_dump when custom hash table is taken into account.
So , to sum up. I can not find any not working part of code with only
read and write property hook , except this one for print_r and
var_dump.
>Please discuss custom extension writing in >pecl-dev@lists.php.net
mailing list.
Will try :)
Previous Comments:
------------------------------------------------------------------------
[2007-02-14 11:03:32] tony2001@php.net
Of course get_properties() is required, how else do you think it should
work? You need to know the name of the property to be able to call
read_property().
The fact that you can't find any docs for get_properties()(which is
implemented quite a number of times in PHP sources) is hardly a PHP
bug.
Please discuss custom extension writing in pecl-dev@lists.php.net
mailing list.
------------------------------------------------------------------------
[2007-02-14 09:56:01] piotrek dot pokora at gmail dot com
Description:
------------
zend_print_zval_r_ex uses object's get_properties handler and prints
properties HashTable without using read_property handler.
For custom object handlers hooks it means that get_properties should be
also implemented as hook which leads to too much overloaded
implementation as get_properties seems to be invoked for read and write
hooks.
Taking performance into account , one would sacrifice performance
problem for print_r ( which is not used in real production environment
) which could use object's read_property handler hook.
Reproduce code:
---------------
Implement read and write property hooks for object.
Assuming that property's data is set in C extension one is able to
call:
echo $object->prop;
which prints property's value, while
print_r($object);
prints object's properties without values.
I know I can implement own get_properties hook , but unfortunatelly I
can not find suitable docs for such implementation.
I think one should be able to reproduce it with mysqli extension which
implement only get and read property hooks.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40477&edit=1