Hello,
This patch for 5.2 provides an alternative error when you accidentally call
__get() recursively when trying to access some property of a class.
Currently, PHP says:
"Notice: Undefined property: someClass::$someProperty"
which makes it seem as though __get() is not called at all. This patch changes
the error to:
"Warning: Recursive call to __get() trying to read property:
someClass::$someProperty"
regards,
Peter
--- Zend.original/zend_object_handlers.c Fri Dec 22 10:36:32 2006
+++ Zend/zend_object_handlers.c Fri Dec 22 10:47:29 2006
@@ -325,30 +325,40 @@
zend_guard *guard;
if (zobj->ce->__get &&
- zend_get_property_guard(zobj, property_info, member, &guard) == SUCCESS
&&
- !guard->in_get) {
- /* have getter - try with it! */
- guard->in_get = 1; /* prevent circular getting */
- rv = zend_std_call_getter(object, member TSRMLS_CC);
- guard->in_get = 0;
+ zend_get_property_guard(zobj, property_info, member, &guard) == SUCCESS)
{
+ /* only if not already in __get() */
+ if(!guard->in_get) {
+ /* have getter - try with it! */
+ guard->in_get = 1; /* prevent circular getting */
+ rv = zend_std_call_getter(object, member TSRMLS_CC);
+ guard->in_get = 0;
- if (rv) {
- retval = &rv;
- if (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) {
- if (rv->refcount > 0) {
- zval *tmp = rv;
+ if (rv) {
+ retval = &rv;
+ if (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) {
+ if (rv->refcount > 0) {
+ zval *tmp = rv;
- ALLOC_ZVAL(rv);
- *rv = *tmp;
- zval_copy_ctor(rv);
- rv->is_ref = 0;
- rv->refcount = 0;
- }
- if (Z_TYPE_P(rv) != IS_OBJECT) {
- zend_error(E_NOTICE, "Indirect modification of overloaded property
%s::$%s has no effect", zobj->ce->name, Z_STRVAL_P(member));
+ ALLOC_ZVAL(rv);
+ *rv = *tmp;
+ zval_copy_ctor(rv);
+ rv->is_ref = 0;
+ rv->refcount = 0;
+ }
+ if (Z_TYPE_P(rv) != IS_OBJECT) {
+ zend_error(E_NOTICE, "Indirect modification of overloaded property
%s::$%s has no effect", zobj->ce->name, Z_STRVAL_P(member));
+ }
}
+ } else {
+ retval = &EG(uninitialized_zval_ptr);
+ }
+ }
+ else {
+ /* already in __get() */
+ if (!silent) {
+ zend_error(E_WARNING, "Recursive call to __get() trying to read property:
%s::$%s",
+ zobj->ce->name, Z_STRVAL_P(member));
}
- } else {
retval = &EG(uninitialized_zval_ptr);
}
} else {
Send instant messages to your online friends http://au.messenger.yahoo.com