Reply to ticks, debug_backtrace, PHP5

Your name:

Reply:


Posted by Bent Stigsen on 01/21/06 10:59

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
nudge).

To check:...

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

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

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

register_tick_function('__tick_function');
echo sub1('Hello');

function __tick_function() {
echo __FUNCTION__, ':', PHP_EOL;
debug_print_backtrace();
echo '------------------', PHP_EOL;
unregister_tick_function(__FUNCTION__);
}
?>


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

__tick_function:
#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]
------------------
sub2:
#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...

__tick_function:
#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]
------------------
sub2:
#0 sub2(Hello world) called at [...\ticks_and_backtrace.php:5]
#1 sub1(Hello) called at [...\ticks_and_backtrace.php:18]


/Bent

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация