Req #71543 [Com]: add ini setting for debug_backtrace to show argument values as passed

From: Date: Sun, 07 Feb 2016 22:14:03 +0000
Subject: Req #71543 [Com]: 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-199097@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 Comment by: support at excsitement dot com Reported by: support at excsitement dot com Summary: add ini setting for debug_backtrace to show argument values as passed Status: Open Type: Feature/Change Request Package: Scripting Engine problem PHP Version: 7.0.3 Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#199097) next »