Req #71543 [NEW]: configuration setting to make debug_backtrace show arguments correctly
| From: | support at excsitement dot com | Date: | Sun, 07 Feb 2016 16:14:33 +0000 |
| Subject: | Req #71543 [NEW]: configuration setting to make debug_backtrace show arguments correctly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-199094@lists.php.net to get a copy of this message | ||
From: support at excsitement dot com
Operating system:
PHP version: 7.0.3
Package: Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:configuration setting to make debug_backtrace show arguments correctly
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 bug report at https://bugs.php.net/bug.php?id=71543&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71543&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71543&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71543&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71543&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71543&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71543&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71543&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71543&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71543&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71543&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71543&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71543&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71543&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71543&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71543&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71543&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71543&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71543&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71543&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71543&r=mysqlcfg