php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39070 debug_backtrace output when call_user_func or error handler involved
Submitted: 2006-10-06 20:16 UTC Modified: 2021-10-08 16:54 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (50.0%)
From: alan dot harder at sun dot com Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.0 OS: *
Private report: No CVE-ID: None
 [2006-10-06 20:16 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 16:15 UTC] 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.
 [2021-10-08 16:54 UTC] cmb@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: cmb
 [2021-10-08 16:54 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 18:01:33 2024 UTC