Skip to content

Commit 6fd13d0

Browse files
morrisonlevinikic
authored andcommitted
Fix function/file mixup in backtrace printing
The error says "Function name" is not a string, but it's actually investigating the "file" field, not "function". Closes GH-6768.
1 parent ec24f14 commit 6fd13d0

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Zend/tests/bug63762.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ string(36) "#0 [internal function]: ()
3939

4040
Array of array of NULL values:
4141

42-
Warning: Function name is not a string in %s on line %d
42+
Warning: File name is not a string in %s on line %d
4343

4444
Warning: Value for class is not a string in %s on line %d
4545

@@ -48,5 +48,5 @@ Warning: Value for type is not a string in %s on line %d
4848
Warning: Value for function is not a string in %s on line %d
4949

5050
Warning: args element is not an array in %s on line %d
51-
string(60) "#0 [unknown function][unknown][unknown][unknown]()
51+
string(58) "#0 [unknown file]: [unknown][unknown][unknown]()
5252
#1 {main}"

Zend/zend_exceptions.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,20 +543,17 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
543543
file = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_FILE), 1);
544544
if (file) {
545545
if (Z_TYPE_P(file) != IS_STRING) {
546-
zend_error(E_WARNING, "Function name is not a string");
547-
smart_str_appends(str, "[unknown function]");
546+
zend_error(E_WARNING, "File name is not a string");
547+
smart_str_appends(str, "[unknown file]: ");
548548
} else{
549-
zend_long line;
549+
zend_long line = 0;
550550
tmp = zend_hash_find_ex(ht, ZSTR_KNOWN(ZEND_STR_LINE), 1);
551551
if (tmp) {
552552
if (Z_TYPE_P(tmp) == IS_LONG) {
553553
line = Z_LVAL_P(tmp);
554554
} else {
555555
zend_error(E_WARNING, "Line is not an int");
556-
line = 0;
557556
}
558-
} else {
559-
line = 0;
560557
}
561558
smart_str_append(str, Z_STR_P(file));
562559
smart_str_appendc(str, '(');

0 commit comments

Comments
 (0)