diff options
Diffstat (limited to 'Zend/zend_object_handlers.c')
-rw-r--r-- | Zend/zend_object_handlers.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 093951eeca..bc65313962 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -137,8 +137,37 @@ ZEND_API HashTable *zend_std_get_gc(zval *object, zval ***table, int *n TSRMLS_D ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ { - *is_temp = 0; - return zend_std_get_properties(object TSRMLS_CC); + zend_class_entry *ce = Z_OBJCE_P(object); + zval *retval = NULL; + + if (!ce->__debugInfo) { + *is_temp = 0; + return Z_OBJ_HANDLER_P(object, get_properties) + ? Z_OBJ_HANDLER_P(object, get_properties)(object TSRMLS_CC) + : NULL; + } + + zend_call_method_with_0_params(&object, ce, &ce->__debugInfo, ZEND_DEBUGINFO_FUNC_NAME, &retval); + if (retval && Z_TYPE_P(retval) == IS_ARRAY) { + HashTable *ht = Z_ARRVAL_P(retval); + if (Z_REFCOUNT_P(retval) <= 1) { + *is_temp = 1; + efree(retval); + return ht; + } else { + *is_temp = 0; + zval_ptr_dtor(&retval); + } + return ht; + } + if (retval && Z_TYPE_P(retval) == IS_NULL) { + zval ret; + array_init(&ret); + *is_temp = 1; + return Z_ARRVAL(ret); + } + + zend_error_noreturn(E_ERROR, ZEND_DEBUGINFO_FUNC_NAME "() must return an array"); } /* }}} */ @@ -896,11 +925,8 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ zend_call_method_with_2_params(&this_ptr, ce, &ce->__call, ZEND_CALL_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr); if (method_result_ptr) { - if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) { - RETVAL_ZVAL(method_result_ptr, 1, 1); - } else { - RETVAL_ZVAL(method_result_ptr, 0, 1); - } + RETVAL_ZVAL_FAST(method_result_ptr); + zval_ptr_dtor(&method_result_ptr); } /* now destruct all auxiliaries */ @@ -1113,11 +1139,8 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ zend_call_method_with_2_params(NULL, ce, &ce->__callstatic, ZEND_CALLSTATIC_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr); if (method_result_ptr) { - if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) { - RETVAL_ZVAL(method_result_ptr, 1, 1); - } else { - RETVAL_ZVAL(method_result_ptr, 0, 1); - } + RETVAL_ZVAL_FAST(method_result_ptr); + zval_ptr_dtor(&method_result_ptr); } /* now destruct all auxiliaries */ @@ -1644,9 +1667,11 @@ ZEND_API zend_object_handlers std_object_handlers = { zend_std_compare_objects, /* compare_objects */ zend_std_cast_object_tostring, /* cast_object */ NULL, /* count_elements */ - NULL, /* get_debug_info */ + zend_std_get_debug_info, /* get_debug_info */ zend_std_get_closure, /* get_closure */ zend_std_get_gc, /* get_gc */ + NULL, /* do_operation */ + NULL, /* compare */ }; /* |