mirror of
https://github.com/php/php-src.git
synced 2026-04-28 18:53:33 +02:00
Fixed bug #30828 (debug_backtrace() reports incorrect class in overridden methods)
This commit is contained in:
@@ -137,6 +137,8 @@ PHP NEWS
|
||||
(Dmitry)
|
||||
- Fixed bug #30889 (Conflict between __get/__set and ++ operator). (Dmitry)
|
||||
- Fixed bug #30833 (array_count_values() modifying input array). (Tony)
|
||||
- Fixed bug #30828 (debug_backtrace() reports incorrect class in overridden
|
||||
methods). (Dmitry)
|
||||
- Fixed bug #30820 (static member conflict with $this->member silently
|
||||
ignored). (Dmitry)
|
||||
- Fixed bug #30819 (Better support for LDAP SASL bind). (Jani)
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
--TEST--
|
||||
Bug #30828 (debug_backtrace() reports incorrect class in overridden methods)
|
||||
--FILE--
|
||||
<?php
|
||||
class A {
|
||||
function __construct() {
|
||||
debug_print_backtrace();
|
||||
$bt = debug_backtrace();
|
||||
foreach ($bt as $t) {
|
||||
print $t['class'].$t['type'].$t['function']."\n";
|
||||
}
|
||||
}
|
||||
|
||||
function foo() {
|
||||
debug_print_backtrace();
|
||||
$bt = debug_backtrace();
|
||||
foreach ($bt as $t) {
|
||||
print $t['class'].$t['type'].$t['function']."\n";
|
||||
}
|
||||
}
|
||||
|
||||
static function bar() {
|
||||
debug_print_backtrace();
|
||||
$bt = debug_backtrace();
|
||||
foreach ($bt as $t) {
|
||||
print $t['class'].$t['type'].$t['function']."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function foo() {
|
||||
parent::foo();
|
||||
}
|
||||
|
||||
static function bar() {
|
||||
parent::bar();
|
||||
}
|
||||
}
|
||||
|
||||
$b = new B();
|
||||
$b->foo();
|
||||
B::bar();
|
||||
?>
|
||||
--EXPECTF--
|
||||
#0 A->__construct() called at [%sbug30828.php:30]
|
||||
#1 B->__construct() called at [%sbug30828.php:42]
|
||||
A->__construct
|
||||
B->__construct
|
||||
#0 A->foo() called at [%sbug30828.php:34]
|
||||
#1 B->foo() called at [%sbug30828.php:43]
|
||||
A->foo
|
||||
B->foo
|
||||
#0 A::bar() called at [%sbug30828.php:38]
|
||||
#1 B::bar() called at [%sbug30828.php:44]
|
||||
A::bar
|
||||
B::bar
|
||||
@@ -1620,13 +1620,16 @@ ZEND_FUNCTION(debug_print_backtrace)
|
||||
|
||||
if (function_name) {
|
||||
if (ptr->object) {
|
||||
zend_uint class_name_len;
|
||||
if (Z_OBJ_HT_P(ptr->object)->get_class_name == NULL ||
|
||||
Z_OBJ_HT_P(ptr->object)->get_class_name(ptr->object, &class_name, &class_name_len, 0 TSRMLS_CC) != SUCCESS) {
|
||||
|
||||
class_name = Z_OBJCE(*ptr->object)->name;
|
||||
if (ptr->function_state.function->common.scope) {
|
||||
class_name = ptr->function_state.function->common.scope->name;
|
||||
} else {
|
||||
free_class_name = class_name;
|
||||
zend_uint class_name_len;
|
||||
if (Z_OBJ_HT_P(ptr->object)->get_class_name == NULL ||
|
||||
Z_OBJ_HT_P(ptr->object)->get_class_name(ptr->object, &class_name, &class_name_len, 0 TSRMLS_CC) != SUCCESS) {
|
||||
class_name = Z_OBJCE(*ptr->object)->name;
|
||||
} else {
|
||||
free_class_name = class_name;
|
||||
}
|
||||
}
|
||||
call_type = "->";
|
||||
} else if (ptr->function_state.function->common.scope) {
|
||||
@@ -1778,12 +1781,16 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last TSRML
|
||||
add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);
|
||||
|
||||
if (ptr->object && Z_TYPE_P(ptr->object) == IS_OBJECT) {
|
||||
zend_uint class_name_len;
|
||||
if (Z_OBJ_HT_P(ptr->object)->get_class_name == NULL ||
|
||||
Z_OBJ_HT_P(ptr->object)->get_class_name(ptr->object, &class_name, &class_name_len, 0 TSRMLS_CC) != SUCCESS) {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), Z_OBJCE(*ptr->object)->name, 1);
|
||||
if (ptr->function_state.function->common.scope) {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, 1);
|
||||
} else {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 0);
|
||||
zend_uint class_name_len;
|
||||
if (Z_OBJ_HT_P(ptr->object)->get_class_name == NULL ||
|
||||
Z_OBJ_HT_P(ptr->object)->get_class_name(ptr->object, &class_name, &class_name_len, 0 TSRMLS_CC) != SUCCESS) {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), Z_OBJCE(*ptr->object)->name, 1);
|
||||
} else {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 0);
|
||||
}
|
||||
}
|
||||
add_assoc_string_ex(stack_frame, "type", sizeof("type"), "->", 1);
|
||||
} else if (ptr->function_state.function->common.scope) {
|
||||
|
||||
Reference in New Issue
Block a user