php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71543 add ini setting for debug_backtrace to show argument values as passed
Submitted: 2016-02-07 16:14 UTC Modified: 2018-07-08 20:11 UTC
From: support at excsitement dot com Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: 7.0.3 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-02-07 16:14 UTC] support at excsitement dot com
Description:
------------
in php 7 debug_backtrace no longer shows argument values as they were passed to the function, showing instead the values at the moment of the next call in the trace

official php page (http://php.net/manual/en/migration70.incompatible.php) doesn't mention this change, only informing of similar change to behavior of func_get_arg(s), but in comments to bug 70547 https://bugs.php.net/bug.php?id=70547 change was described as intended performance optimization with reference to these notes: http://git.php.net/?p=php-src.git;a=blob;f=UPGRADING;h=aa5f82c49abf4e36476b328c2fc8820d4672c72a;hb=refs/heads/PHP-7.0#l190

While change to the func_get_arg(s) seem harmless (they can be simply used in the very beginning of the function), backtace that shows function calls with arguments values different from what were passed is very confusing. There're many situations when function gets an argument, modifies it, passes to yet another function etc. When debugging them, new backtrace confuses instead of helping.

Suggestion: if it is important for the performance not to store the copies of the arguments, add ini setting that will toggle between old and new behavior, giving developer an option to choose between better debugging capabilities and better performance

Test script:
---------------
function func($arg)
{
$arg['something'] = 2;
print_r(debug_backtrace()[0]);
}
func(['something' => 1]);

Expected result:
----------------
Array
(
    [function] => func
    [args] => Array
        (
            [0] => Array
                (
                    [something] => 1
                )

        )

)

Actual result:
--------------
Array
(
    [function] => func
    [args] => Array
        (
            [0] => Array
                (
                    [something] => 2
                )

        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-07 16:25 UTC] support at excsitement dot com
-Summary: configuration setting to make debug_backtrace show arguments correctly +Summary: add ini setting for debug_backtrace to show argument values as passed
 [2016-02-07 16:25 UTC] support at excsitement dot com
corrected title
 [2016-02-07 22:14 UTC] support at excsitement dot com
Added separate DOC BUG https://bugs.php.net/bug.php?id=71547 about new behavior not being in official documentation, so this one is solely a feature suggestion
 [2018-07-08 20:11 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2018-07-08 20:11 UTC] cmb@php.net
This feature request would certainly require discussion on the
internals@ mailing list, and possibly the RFC process.  For the
time being, I'm suspending this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC