Edit report at https://bugs.php.net/bug.php?id=55731&edit=1
ID: 55731
Comment by: ocramius at gmail dot com
Reported by: 421034509 at qq dot com
Summary: __get after __unset
Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: windows xp
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
I got pointed here after filing #63462 ( https://bugs.php.net/bug.php?id=63462 ).
Shouldn't the getter_guard be disabled for "\0Example\0p1: (laurence's
example) when already in the context of __get (and similar logic for all the other
magic methods)?
I have absolutely no understanding of PHP internals about this, but I wouldn't expect the magic
getter to work again for the same property when we already know it was the requested one.
This is actually a (quite problematic) bug for me since it denies any action on unset properties,
which is a feature I need when working with proxies.
If I understand this correctly, at https://github.com/php/php-src/blob/6ba376f552238de643a665d355fd5e59c40315b5/Zend/zend_object_handlers.c#L559-572
the guard is used. I don't understand why guard->in_set isn't checked the
second time though. Does zend_get_property_guard retrieve a different item for
different property_info?
Previous Comments:
------------------------------------------------------------------------
[2011-09-22 03:36:35] 421034509 at qq dot com
Thank you!I got it!
------------------------------------------------------------------------
[2011-09-22 01:28:25] laruence@php.net
No, if the property is private, and the getter is called out of call entry(means
access a private property out of scope), zend vm will return NULL, but
zend_read_property will assume as a "public property name", since PHP is a
flexible language.
------------------------------------------------------------------------
[2011-09-22 01:18:53] 421034509 at qq dot com
When get_property_info successed in the Example class,
if the private property is defined but be unsetted,zend vm return a property info with name
"\0Example\0propertyname",
but if the property is undefined(or defined but not be unsetted),zend vm return a property info with
name "propertyname".
Is that true?
------------------------------------------------------------------------
[2011-09-22 01:17:55] laruence@php.net
because there is no '\0Example\0p3' in property_info of Example class entry
------------------------------------------------------------------------
[2011-09-21 16:51:52] hytest at gmail dot com
If we add following code:
echo $example->p3;
It still just call __get once. Why it doesn't call it twice?
( one for "p3" and one for "\0example\0p3" ? )
In another word: what's the different between a property not defined and a unset
private property?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=55731--
Edit this bug report at https://bugs.php.net/bug.php?id=55731&edit=1