Req #39070 [Opn->Csd]: debug_backtrace output when call_user_func or error handler involved
| From: | cmb@php.net | Date: | Fri, 08 Oct 2021 16:54:45 +0000 |
| Subject: | Req #39070 [Opn->Csd]: debug_backtrace output when call_user_func or error handler involved | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237109@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39070&edit=1
ID: 39070
Updated by: cmb@php.net
Reported by: alan dot harder at sun dot com
Summary: debug_backtrace output when call_user_func or error
handler involved
-Status: Open
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: *
PHP Version: 5.2.0
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
PHP 4 and 5 are no longer relevant, and it seems that actively
supported versions[1] behave as desired[2].
[1] <https://www.php.net/supported-versions.php>
[2] <https://3v4l.org/ieOGP>
Previous Comments:
------------------------------------------------------------------------
[2007-08-17 16:15:13] vrana@php.net
Both PHP 4 and PHP 5 can be improved:
PHP 5 should fill file and line as PHP 4 do.
PHP 4 should list 'my_func' only once as PHP 5 do.
------------------------------------------------------------------------
[2006-10-06 20:16:51] alan dot harder at sun dot com
Description:
------------
I have found some inconsistencies in the behavior of debug_backtrace. I'm not sure either of
these are bugs, so I'm filing this under documentation.
1) If call_user_func is used, debug_backtrace output includes an array entry with no file/line info.
Seems to be the case with PHP versions as far back as 4.3.0.
debug_backtrace docs do say these are the "possible" values to be in the backtrace, but
doesn't list any conditions where file/line might be omitted. If this behavior in the
debug_backtrace output is expected, then maybe document this here.
2) If an error handler is invoked, debug_backtrace output differs between PHP versions. PHP 4.x has
2 entries (one with error handler and its params, another with file/line where error occurred).. PHP
5.1.x and 5.2.0RC5 combine these into a single entry (didn't text 5.0.x). Maybe this is
related, not sure: http://bugs.php.net/bug.php?id=34175
Perhaps this should be a ChangeLog entry on the docs page for debug_backtrace.
Reproduce code:
---------------
<pre><?php
function my_func() { 1 / 0; }
function do_backtrace() { print_r(debug_backtrace()); }
set_error_handler('do_backtrace');
call_user_func('my_func');
?></pre>
Expected result:
----------------
Output that can be predicted by reading the debug_backtrace docs.
Actual result:
--------------
file/line missing for entry after call_user_func, and array length differs between PHP 4.x and
5.1.x/5.2.0.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=39070&edit=1