Moved Db::_formatBacktrace() to Functions::FormatBacktrace()
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 20 Dec 2006 01:28:37 +0000 (01:28 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 20 Dec 2006 01:28:37 +0000 (01:28 +0000)
Db.php
Functions.php
Register.php

diff --git a/Db.php b/Db.php
index 0bbc645e18b608d63f511953265ba0eb7b66bdf8..7fbb29e6f10a7ce86b30882f613c320fa8751624 100644 (file)
--- 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 <pear@laurent-laville.org>
-       * @author       Aidan Lister <aidan@php.net>
-       *
-       * @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);
-       }
 }
 
 /*=====================================================================*\
index fb30b65f8d1e48d3fee44e951980a7e5fd2cea11..59806eb12cfbb59872e06e579e407210d2a27ace 100644 (file)
@@ -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 <pear@laurent-laville.org>
+       * @author       Aidan Lister <aidan@php.net>
+       *
+       * @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);
+       }
 }
 
 /*=====================================================================*\
index 79af67076ee416978eb9d5ceb9ae5eaf01d4f5a0..68cbc7917968d9ebb308786cf7f4245585cac3f0 100644 (file)
@@ -428,7 +428,7 @@ class BSRegister
                if ($stack AND self::Instance()->getDebug())
                {
                        echo "\n<tr style=\"background-color: #FFFFFF; text-align: left\">\n\t<td><strong>Debug Stack:</strong> <pre>";
-                       debug_print_backtrace();
+                       echo BSFunctions::FormatBacktrace(debug_backtrace());
                        echo "</pre></td>\n</tr>";
                }
                echo "\n</table>\n<br />\n";