From: k at phpkoala dot com Operating system: Linux PHP version: 5.1.2 PHP Bug Type: Scripting Engine problem Bug description: debug_backtrace information has mixed scope
Description: ------------ When I call debug_backtrace, I find that the results do not match expectations. Specifically, the line number does not match the values for function and class. As shown below, I would expect to see the line number match the values for function and class, at the point referenced. If this point is deemed to be the point where debug_backtrace is called from, then I would expect the details to show the function and class in scope at the line number that debug_backtrace was called, and then as the next most recent entry, the line number etc. for the code that called the function containing the debug_backtrace command. Otherwise, if the reported details should ignore the point in the code that calls debug_backtrace (the current scope at that point) then that entry should not be reported, and the function and class should be relative to the line number that called the function. It would appear that the second of these two options is intended, but that the function and class are being reported for the scope "now" (when debug_backtrace is called) rather than "then" (the last call, i.e. the call to the function) which is what the line number reports. To further clarify; I would expect the output to match the details that would be shown if I used __FILE__, __LINE__, __FUNCTION__, __CLASS__ at each call point. Surely these should all match up...? I am running dot-deb packages for PHP 5.1.2. No customisations. This issue also occurs on PHP 4.3.10. Reproduce code: --------------- <?php class test { function check1() { print_r(debug_backtrace()); } function check2() { self::check1(); // Line 8 } } echo "Test 1:\n\n"; test::check1(); // Line 13 echo "\n\nTest 2:\n\n"; test::check2(); // Line 16 Expected result: ---------------- Test 1: Array ( [0] => Array ( [file] => /home/test.php [line] => 13 [function] => [class] => [type] => [args] => ) ) Test 2: Array ( [0] => Array ( [file] => /home/test.php [line] => 8 [function] => check2 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 16 [function] => [class] => [type] => [args] => ) ) -------------------- OR -------------------- Test 1: Array ( [0] => Array ( [file] => /home/test.php [line] => 5 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 13 [function] => [class] => [type] => [args] => ) ) Test 2: Array ( [0] => Array ( [file] => /home/test.php [line] => 5 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 8 [function] => check2 [class] => test [type] => :: [args] => Array ( ) ) [2] => Array ( [file] => /home/test.php [line] => 16 [function] => [class] => [type] => [args] => ) ) Actual result: -------------- Test 1: Array ( [0] => Array ( [file] => /home/test.php [line] => 13 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) ) Test 2: Array ( [0] => Array ( [file] => /home/test.php [line] => 8 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 16 [function] => check2 [class] => test [type] => :: [args] => Array ( ) ) ) -- Edit bug report at http://bugs.php.net/?id=36883&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36883&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36883&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36883&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36883&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36883&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36883&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36883&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36883&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36883&r=support Expected behavior: http://bugs.php.net/fix.php?id=36883&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36883&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36883&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36883&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36883&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36883&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36883&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36883&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36883&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36883&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36883&r=mysqlcfg