From 4e901318274272d7c2e9a0c4974262d7cdfcfd9b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 20 Dec 2006 01:28:37 +0000 Subject: [PATCH] Moved Db::_formatBacktrace() to Functions::FormatBacktrace() --- Db.php | 67 +-------------------------------------------------- Functions.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ Register.php | 2 +- 3 files changed, 67 insertions(+), 67 deletions(-) diff --git a/Db.php b/Db.php index 0bbc645..7fbb29e 100644 --- a/Db.php +++ b/Db.php @@ -172,7 +172,7 @@ abstract class BSDb $this->_error('Invalid SQL query'); } - $this->history[] = $history = array('query' => $string, 'time' => BSFunctions::FetchMicrotimeDiff($time), 'trace' => $this->_formatBacktrace(debug_backtrace())); + $this->history[] = $history = array('query' => $string, 'time' => BSFunctions::FetchMicrotimeDiff($time), 'trace' => BSFunctions::FormatBacktrace(debug_backtrace())); if (defined('ISSO_SHOW_QUERIES_LIVE')) { @@ -494,71 +494,6 @@ abstract class BSDb exit; } } - - // ################################################################### - /** - * A backtrace formatter. - * - * This is very slightly modified from PEAR/PHP_Compat (PHP license) - * - * @author Laurent Laville - * @author Aidan Lister - * - * @param array The backtrace from debug_backtrace() to format - * - * @return string Formatted output - */ - private function _formatBacktrace($backtrace) - { - // Unset call to debug_print_backtrace - array_shift($backtrace); - if (empty($backtrace)) - { - return ''; - } - - // Iterate backtrace - $calls = array(); - foreach ($backtrace AS $i => $call) - { - if (!isset($call['file'])) - { - $call['file'] = '(null)'; - } - if (!isset($call['line'])) - { - $call['line'] = '0'; - } - $location = $call['file'] . ':' . $call['line']; - $function = (isset($call['class'])) ? $call['class'] . (isset($call['type']) ? $call['type'] : '.') . $call['function'] : $call['function']; - - $params = ''; - if (isset($call['args'])) - { - $args = array(); - foreach ($call['args'] AS $arg) - { - if (is_array($arg)) - { - $args[] = print_r($arg, true); - } - elseif (is_object($arg)) - { - $args[] = get_class($arg); - } - else - { - $args[] = $arg; - } - } - $params = implode(', ', $args); - } - - $calls[] = sprintf('#%d %s(%s) called at [%s]', $i, $function, $params, $location); - } - - return implode("\n", $calls); - } } /*=====================================================================*\ diff --git a/Functions.php b/Functions.php index fb30b65..59806eb 100644 --- a/Functions.php +++ b/Functions.php @@ -646,6 +646,71 @@ class BSFunctions } return $array; } + + // ################################################################### + /** + * A backtrace formatter. + * + * This is very slightly modified from PEAR/PHP_Compat (PHP license) + * + * @author Laurent Laville + * @author Aidan Lister + * + * @param array The backtrace from debug_backtrace() to format + * + * @return string Formatted output + */ + public static function FormatBacktrace($backtrace) + { + // Unset call to debug_print_backtrace + array_shift($backtrace); + if (empty($backtrace)) + { + return ''; + } + + // Iterate backtrace + $calls = array(); + foreach ($backtrace AS $i => $call) + { + if (!isset($call['file'])) + { + $call['file'] = '(null)'; + } + if (!isset($call['line'])) + { + $call['line'] = '0'; + } + $location = $call['file'] . ':' . $call['line']; + $function = (isset($call['class'])) ? $call['class'] . (isset($call['type']) ? $call['type'] : '.') . $call['function'] : $call['function']; + + $params = ''; + if (isset($call['args'])) + { + $args = array(); + foreach ($call['args'] AS $arg) + { + if (is_array($arg)) + { + $args[] = 'Array'; + } + elseif (is_object($arg)) + { + $args[] = get_class($arg); + } + else + { + $args[] = $arg; + } + } + $params = implode(', ', $args); + } + + $calls[] = sprintf('#%d %s(%s) called at [%s]', $i, $function, $params, $location); + } + + return implode("\n", $calls); + } } /*=====================================================================*\ diff --git a/Register.php b/Register.php index 79af670..68cbc79 100644 --- a/Register.php +++ b/Register.php @@ -428,7 +428,7 @@ class BSRegister if ($stack AND self::Instance()->getDebug()) { echo "\n\n\tDebug Stack:
";
-			debug_print_backtrace();
+			echo BSFunctions::FormatBacktrace(debug_backtrace());
 			echo "
\n"; } echo "\n\n
\n"; -- 2.43.5