From 3f3d0c79e9841e406acbda2d8f07021a33be6f4d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 16 Oct 2003 16:34:45 +0000 Subject: [PATCH] added function to generate a function-name backtrace --- phpgwapi/inc/common_functions.inc.php | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/common_functions.inc.php b/phpgwapi/inc/common_functions.inc.php index 8211ecca20..d44af5181e 100755 --- a/phpgwapi/inc/common_functions.inc.php +++ b/phpgwapi/inc/common_functions.inc.php @@ -32,6 +32,7 @@ @collection_start direct functions @abstract Direct functions which are not part of the API classes because they are required to be available at the lowest level. */ + /*! @function print_debug_subarray @abstract Not to be used directly. Should only be used by print_debug() @@ -730,6 +731,17 @@ } } + if (!method_exists($GLOBALS[$classname],$functionname)) + { + $module = $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(PHPGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']); + + echo "

$module: no methode '$functionname' in class '$classname'

\n"; + if (function_exists('debug_backtrace')) + { + echo '

Debug-backtrace

'.print_r(debug_backtrace(),True).'
'; + } + return False; + } if ((is_array($functionparams) || $functionparams != '_UNDEF_') && ($functionparams || $functionparams != 'True')) { return $GLOBALS[$classname]->$functionname($functionparams); @@ -1094,7 +1106,7 @@ @param $tables and array of tables to have the prefix prepended to @return array of table names with the prefix prepended */ - + function prepend_tables_prefix($prefix,$tables) { foreach($tables as $key => $value) @@ -1103,4 +1115,29 @@ } return $tables; } + + + /*! + @function function_backtrace + @abstract returns the backtrace of the calling functions + @param $default default to return if the function debug_backtrace is not availible (php<4.3) + @author ralfbecker + @return function-names separated by slashes (beginning with the calling function not this one) + */ + function function_backtrace($default='') + { + if (function_exists('debug_backtrace')) + { + $backtrace = debug_backtrace(); + //echo "
".print_r($backtrace,True)."
\n"; + array_shift($backtrace); // remove ourself + foreach($backtrace as $level) + { + $ret[] = $level['function']; + } + return implode('/',$ret); + } + return $default; + } + ?>