MyBB Community Forums

Full Version: Use debug_backtrace function?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
In MyBB 1.6.5 I can't use debug_backtrace fuction in my plugins, but I have to use this function!
How can I Solve This Problem?!
(2011-11-30, 12:13 PM)mohdows Wrote: [ -> ]http://wiki.mybb.com/index.php/1.6.5#Plu...em_Changes

It didn't have any relation with using debug_backtrace fuction in plugins!
Uhm, debug_backtrace is a PHP function - its availability depends on the environment, not MyBB.
(2011-11-30, 01:28 PM)Tomm M Wrote: [ -> ]Uhm, debug_backtrace is a PHP function - its availability depends on the environment, not MyBB.

It's Certain!
But Since inc/class_plugins.php is changed in MyBB 1.6.5
from(1.6.4):
					$returnargs = call_user_func_array($hook['function'], array(&$arguments));


to(1.6.5):
				$func = $hook['function'];
				$returnargs = $func($arguments);

The Plugin Can't fetch debug_backtrace() arguments!
can you provide a sample of how you are using the function? perhaps one of your plugins that we can look at?
This is an example of it(written by imei modified by me!)
function imeiJalaliDate($date)
{
  global $mybb, $lang;

	$callinfo=debug_backtrace();
	$callinfos=$callinfo[3];
	if($callinfo[4]['function']=="get_age"){
		return $date;
	}
	//imeiJalaliDate>Call_User_Func_Array(PluginClass)>Run_hook_by_ref(functions)>my_date(functions)
	if(!isset($callinfos['args'])){
		var_dump(debug_backtrace());
		//we have an error in back tracking, may be famous bug of php 5
		die("Error! Can't fetch debug_backtrace() arguments. It is a bug in your PHP handler or an Exception in JalaliDate Plugin. Please Upgrade your PHP and/or Send above detailes to plugin vendor.");
		return $date;
	}
		return $date;
}

And I'll get this error:
array(3) { [0]=> array(4) { ["file"]=> string(33) "C:\wamp\www\inc\class_plugins.php" ["line"]=> int(106) 

["function"]=> string(14) "imeiJalaliDate" ["args"]=> array(1) { [0]=> &string(4) "2011" } } [1]=> array(7) { ["file"]=> 

string(29) "C:\wamp\www\inc\functions.php" ["line"]=> int(399) ["function"]=> string(9) "run_hooks" ["class"]=> string(12)

 "pluginSystem" ["object"]=> object(pluginSystem)#7
Error! Can't fetch debug_backtrace() arguments. It is a bug in your PHP handler or an Exception in JalaliDate Plugin. Please 

Upgrade your PHP and/or Send above detailes to plugin vendor.

But When I Use The class_plugins.php ver:1.6.4 It works without any errors!
since the plugin system does not use call_user_func method anymore, the debug_backtrace results are probably shifted one level so you need to change the 4 to a 3 I think.
(2011-11-30, 04:27 PM)pavemen Wrote: [ -> ]since the plugin system does not use call_user_func method anymore, the debug_backtrace results are probably shifted one level so you need to change the 4 to a 3 I think.

Thank You!
It Worked!
But not 4->3
3->2 is the correct.

By The Way, Thanks alot!