ticks, debug_backtrace, PHP5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I couldn't find it mentioned anywhere, so just in case someone else  
should run into this.

Function arguments in the result from "debug_backtrace" or  
"debug_print_backtrace", when called from a registered tick_function,  
is out of sync.

I couldn't find an exact match at bugs.php.net, but assume the bug  
overlaps with this one. http://bugs.php.net/bug.php?id=29896

According to the change log, it should have been fixed from version  
5.1.0, so if your web host or distro is not up to speed, kick and yell  
and/or upgrade, whatever works or makes you feel better.

I checked on a windows(cli), perhaps someone with Linux and PHP>=5.1  
can check it before I get around to upgrading mine (wink wink nudge  

To check:...

header('Content-Type: text/plain');

function sub1($str) {
   return sub2("$str world");

declare(ticks=1) {
   function sub2($str1) {
     ; //tick here
     echo __FUNCTION__, ':', PHP_EOL;
     return "\n\n$str1\n\n";

echo sub1('Hello');

function __tick_function() {
   echo __FUNCTION__, ':', PHP_EOL;
   echo '------------------', PHP_EOL;

This is how the trace output looks on a PHP 5.0.4:...

#0  __tick_function() called at [.../ticks_and_backtrace.php:10]
#1  sub2() called at [.../ticks_and_backtrace.php:10]
#2  sub2() called at [.../ticks_and_backtrace.php:5]
#3  sub1(Hello world) called at [.../ticks_and_backtrace.php:18]
#0  sub2(Hello world) called at [.../ticks_and_backtrace.php:5]
#1  sub1(Hello) called at [.../ticks_and_backtrace.php:18]

... and how it should look...

#0  __tick_function() called at [...\ticks_and_backtrace.php:10]
#1  sub2(Hello world) called at [...\ticks_and_backtrace.php:5]
#2  sub1(Hello) called at [...\ticks_and_backtrace.php:18]
#0  sub2(Hello world) called at [...\ticks_and_backtrace.php:5]
#1  sub1(Hello) called at [...\ticks_and_backtrace.php:18]


Site Timeline