Req #71543 [Opn->Sus]: add ini setting for debug_backtrace to show argument values as passed
| From: | cmb@php.net | Date: | Sun, 08 Jul 2018 20:11:23 +0000 |
| Subject: | Req #71543 [Opn->Sus]: add ini setting for debug_backtrace to show argument values as passed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216235@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71543&edit=1
ID: 71543
Updated by: cmb@php.net
Reported by: support at excsitement dot com
Summary: add ini setting for debug_backtrace to show argument
values as passed
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 7.0.3
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2016-02-07 22:14:02] 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
------------------------------------------------------------------------
[2016-02-07 16:25:07] support at excsitement dot com
corrected title
------------------------------------------------------------------------
[2016-02-07 16:14:26] 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
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71543&edit=1