php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #64239
Patch bug64239-2.patch revision 2013-03-21 09:06 UTC by dmitry@php.net
revision 2013-03-21 07:55 UTC by dmitry at zend dot com
Patch bug64329.patch revision 2013-03-21 08:18 UTC by laruence@php.net
Patch bug64239.patch revision 2013-03-21 06:04 UTC by laruence@php.net

Patch bug64239.patch for *General Issues Bug #64239

Patch version 2013-03-21 06:04 UTC

Return to Bug #64239 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: laruence@php.net

diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index ee75f52..787fe8c 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -2053,6 +2053,58 @@ void debug_print_backtrace_args(zval *arg_array TSRMLS_DC)
 	}
 }
 
+ZEND_API void zend_resolve_method_alias_name(zend_function *f, char **alias_name, int *alias_len, int fetch_origin)
+{
+	zend_function *func;
+	HashPosition iterator;
+	zend_class_entry *ce;
+	HashTable *function_table;
+
+	if (f->common.type != ZEND_USER_FUNCTION || *(f->op_array.refcount) < 2) {
+		return;
+	}
+
+	ce = f->common.scope;
+	if (!ce || !ce->trait_aliases) {
+		return;
+	}
+
+	function_table = &ce->function_table;
+	zend_hash_internal_pointer_reset_ex(function_table, &iterator);
+	while (zend_hash_get_current_data_ex(function_table, (void **)&func, &iterator) == SUCCESS) {
+		if (func->op_array.opcodes == f->op_array.opcodes) {
+			char *name;
+			uint len;
+			ulong idx;
+			zend_trait_alias *alias, **alias_ptr;
+			if (zend_hash_get_current_key_ex(function_table, &name, &len, &idx, 0, &iterator) != HASH_KEY_IS_STRING) {
+				return;
+			}
+			--len;
+			if (fetch_origin) {
+				do {
+					alias_ptr = ce->trait_aliases;
+					alias = *alias_ptr;
+					while (alias) {
+						if (alias->alias_len == len && !zend_binary_strncasecmp(name, len, alias->alias, alias->alias_len, len)) {
+							*alias_name = alias->alias;
+							*alias_len = alias->alias_len;
+							return;
+						}
+						alias_ptr++;
+						alias = *alias_ptr;
+					}
+				} while ((ce = ce->parent));
+			} else {
+				*alias_name = name;
+				*alias_len = len;
+				return;
+			}
+		}
+		zend_hash_move_forward_ex(function_table, &iterator);
+	}
+}
+
 /* {{{ proto void debug_print_backtrace([int options[, int limit]]) */
 ZEND_FUNCTION(debug_print_backtrace)
 {
@@ -2106,6 +2158,8 @@ ZEND_FUNCTION(debug_print_backtrace)
 		function_name = ptr->function_state.function->common.function_name;
 
 		if (function_name) {
+			int dummy;
+			zend_resolve_method_alias_name(ptr->function_state.function, &function_name, &dummy, 1);
 			if (ptr->object) {
 				if (ptr->function_state.function->common.scope) {
 					class_name = ptr->function_state.function->common.scope->name;
@@ -2287,8 +2341,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
 		function_name = ptr->function_state.function->common.function_name;
 
 		if (function_name) {
+			int dummy;
+			zend_resolve_method_alias_name(ptr->function_state.function, &function_name, &dummy, 1);
 			add_assoc_string_ex(stack_frame, "function", sizeof("function"), (char*)function_name, 1);
-
 			if (ptr->object && Z_TYPE_P(ptr->object) == IS_OBJECT) {
 				if (ptr->function_state.function->common.scope) {
 					add_assoc_string_ex(stack_frame, "class", sizeof("class"), (char*)ptr->function_state.function->common.scope->name, 1);
@@ -2298,7 +2353,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
 
 					dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC);
 					add_assoc_string_ex(stack_frame, "class", sizeof("class"), (char*)class_name, dup);
-					
+
 				}
 				if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
 					add_assoc_zval_ex(stack_frame, "object", sizeof("object"), ptr->object);
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 19:01:53 2014 UTC