diff --git a/libraries/Error.class.php b/libraries/Error.class.php index f78c3ee101..cd99bb1c71 100644 --- a/libraries/Error.class.php +++ b/libraries/Error.class.php @@ -162,7 +162,7 @@ class PMA_Error extends PMA_Message } catch(Exception $e){ $backtrace = ''; } - if (null === $this->_hash) { + if ($this->_hash === null) { $this->_hash = md5( $this->getNumber() . $this->getMessage() . @@ -246,45 +246,52 @@ class PMA_Error extends PMA_Message } /** - * Display HTML backtrace + * Get HTML backtrace * * @return void */ - public function displayBacktrace() + public function getBacktraceDisplay() { + $retval = ''; + foreach ($this->getBacktrace() as $step) { - echo PMA_Error::relPath($step['file']) . '#' . $step['line'] . ': '; + $retval .= PMA_Error::relPath($step['file']) . '#' . $step['line'] . ': '; if (isset($step['class'])) { - echo $step['class'] . $step['type']; + $retval .= $step['class'] . $step['type']; } - echo $step['function'] . '('; + $retval .= $step['function'] . '('; if (isset($step['args']) && (count($step['args']) > 1)) { - echo "
\n"; + $retval .= "
\n"; foreach ($step['args'] as $arg) { - echo "\t"; - $this->displayArg($arg, $step['function']); - echo ',' . "
\n"; + $retval .= "\t"; + $retval .= $this->getArg($arg, $step['function']); + $retval .= ',' . "
\n"; } } elseif (isset($step['args']) && (count($step['args']) > 0)) { foreach ($step['args'] as $arg) { - $this->displayArg($arg, $step['function']); + $retval .= $this->getArg($arg, $step['function']); } } - echo ')' . "
\n"; + $retval .= ')' . "
\n"; } + + return $retval; } /** - * Display a single function argument - * if $function is one of include/require the $arg is converted te relative path + * Get a single function argument + * + * if $function is one of include/require + * the $arg is converted to a relative path * * @param string $arg * @param string $function * - * @return void + * @return string */ - protected function displayArg($arg, $function) + protected function getArg($arg, $function) { + $retval = ''; $include_functions = array( 'include', 'include_once', @@ -293,37 +300,40 @@ class PMA_Error extends PMA_Message ); if (in_array($function, $include_functions)) { - echo PMA_Error::relPath($arg); + $retval .= PMA_Error::relPath($arg); } elseif (is_scalar($arg)) { - echo gettype($arg) . ' ' . htmlspecialchars($arg); + $retval .= getType($arg) . ' ' . htmlspecialchars($arg); } else { - echo gettype($arg); + $retval .= getType($arg); } + + return $retval; } /** - * Displays the error in HTML + * Gets the error as string of HTML * - * @return void + * return string */ - public function display() + public function getDisplay() { - echo '
'; + $retval = '
'; if (! $this->isUserError()) { - echo '' . $this->getType() . ''; - echo ' in ' . $this->getFile() . '#' . $this->getLine(); - echo "
\n"; + $retval .= '' . $this->getType() . ''; + $retval .= ' in ' . $this->getFile() . '#' . $this->getLine(); + $retval .= "
\n"; } - echo $this->getMessage(); + $retval .= $this->getMessage(); if (! $this->isUserError()) { - echo "
\n"; - echo "
\n"; - echo "Backtrace
\n"; - echo "
\n"; - echo $this->displayBacktrace(); + $retval .= "
\n"; + $retval .= "
\n"; + $retval .= "Backtrace
\n"; + $retval .= "
\n"; + $retval .= $this->getBacktraceDisplay(); } - echo '
'; - $this->isDisplayed(true); + $retval .= '
'; + + return $retval; } /**