X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FError.php;h=2bf7ba92e03997409eee3728851492e5a4d8c7d6;hb=f52694340988cd29f5f80b6392e7662bf33e8bf2;hp=16ac8caf4dd8f7b518a6026b4ad7e9cd868ecdf1;hpb=9726c118a180065a2789e223e74573b0f166851f;p=civicrm-core.git diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 16ac8caf4d..2bf7ba92e0 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -39,34 +39,6 @@ require_once 'CRM/Core/Exception.php'; require_once 'Log.php'; -/** - * Class CRM_Exception - */ -class CRM_Exception extends PEAR_Exception { - - /** - * Redefine the exception so message isn't optional. - * - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * - * @param string $message exception message - * @param int $code - * @param Exception $previous - */ - public function __construct($message = NULL, $code = 0, Exception $previous = NULL) { - parent::__construct($message, $code, $previous); - } - -} - /** * Class CRM_Core_Error */ @@ -232,7 +204,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { $errorDetails = CRM_Core_Error::debug('', $error, FALSE); $template->assign_by_ref('errorDetails', $errorDetails); - CRM_Core_Error::debug_var('Fatal Error Details', $error); + CRM_Core_Error::debug_var('Fatal Error Details', $error, TRUE, TRUE, '', PEAR_LOG_ERR); CRM_Core_Error::backtrace('backTrace', TRUE); if ($config->initialized) { @@ -339,7 +311,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { if (self::$modeException) { // CRM-11043 - CRM_Core_Error::debug_var('Fatal Error Details', $vars); + CRM_Core_Error::debug_var('Fatal Error Details', $vars, TRUE, TRUE, '', PEAR_LOG_ERR); CRM_Core_Error::backtrace('backTrace', TRUE); $details = 'A fatal error was triggered'; @@ -381,7 +353,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { self::backtrace(); } - CRM_Core_Error::debug_var('Fatal Error Details', $vars); + CRM_Core_Error::debug_var('Fatal Error Details', $vars, TRUE, TRUE, '', PEAR_LOG_ERR); CRM_Core_Error::backtrace('backTrace', TRUE); // If we are in an ajax callback, format output appropriately @@ -421,7 +393,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { } catch (Exception $other) { // if the exception-handler generates an exception, then that sucks! oh, well. carry on. - CRM_Core_Error::debug_var('handleUnhandledException_nestedException', self::formatTextException($other)); + CRM_Core_Error::debug_var('handleUnhandledException_nestedException', self::formatTextException($other), TRUE, TRUE, '', PEAR_LOG_ERR); } $config = CRM_Core_Config::singleton(); $vars = [ @@ -459,24 +431,19 @@ class CRM_Core_Error extends PEAR_ErrorStack { // Case C: Default error handler // log to file - CRM_Core_Error::debug_var('Fatal Error Details', $vars, FALSE); + CRM_Core_Error::debug_var('Fatal Error Details', $vars, FALSE, TRUE, '', PEAR_LOG_ERR); CRM_Core_Error::backtrace('backTrace', TRUE); // print to screen $template = CRM_Core_Smarty::singleton(); $template->assign($vars); $content = $template->fetch('CRM/common/fatal.tpl'); + if ($config->backtrace) { $content = self::formatHtmlException($exception) . $content; } - if ($config->userFramework == 'Joomla' && - class_exists('JError') - ) { - JError::raiseError('CiviCRM-001', $content); - } - else { - echo CRM_Utils_System::theme($content); - } + + echo CRM_Utils_System::theme($content); // fin self::abend(CRM_Core_Error::FATAL_ERROR); @@ -544,6 +511,8 @@ class CRM_Core_Error extends PEAR_ErrorStack { * Log or return the output? * @param string $prefix * Prefix for output logfile. + * @param int $priority + * The log priority level. * * @return string * The generated output @@ -551,7 +520,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { * @see CRM_Core_Error::debug() * @see CRM_Core_Error::debug_log_message() */ - public static function debug_var($variable_name, $variable, $print = TRUE, $log = TRUE, $prefix = '') { + public static function debug_var($variable_name, $variable, $print = TRUE, $log = TRUE, $prefix = '', $priority = NULL) { // check if variable is set if (!isset($variable)) { $out = "\$$variable_name is not set"; @@ -574,7 +543,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { reset($variable); } } - return self::debug_log_message($out, FALSE, $prefix); + return self::debug_log_message($out, FALSE, $prefix, $priority); } /** @@ -635,7 +604,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { CRM_Core_Error::backtrace($string, TRUE); } elseif (CIVICRM_DEBUG_LOG_QUERY) { - CRM_Core_Error::debug_var('Query', $string, TRUE, TRUE, 'sql_log'); + CRM_Core_Error::debug_var('Query', $string, TRUE, TRUE, 'sql_log', PEAR_LOG_DEBUG); } } } @@ -647,7 +616,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ public static function debug_query_result($query) { $results = CRM_Core_DAO::executeQuery($query)->fetchAll(); - CRM_Core_Error::debug_var('dao result', ['query' => $query, 'results' => $results]); + CRM_Core_Error::debug_var('dao result', ['query' => $query, 'results' => $results], TRUE, TRUE, '', PEAR_LOG_DEBUG); } /** @@ -731,7 +700,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { CRM_Core_Error::debug($msg, $message); } else { - CRM_Core_Error::debug_var($msg, $message); + CRM_Core_Error::debug_var($msg, $message, TRUE, TRUE, '', PEAR_LOG_DEBUG); } } @@ -948,7 +917,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { * @throws PEAR_Exception */ public static function exceptionHandler($pearError) { - CRM_Core_Error::debug_var('Fatal Error Details', self::getErrorDetails($pearError)); + CRM_Core_Error::debug_var('Fatal Error Details', self::getErrorDetails($pearError), TRUE, TRUE, '', PEAR_LOG_ERR); CRM_Core_Error::backtrace('backTrace', TRUE); throw new PEAR_Exception($pearError->getMessage(), $pearError); } @@ -962,7 +931,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { * $obj */ public static function nullHandler($obj) { - CRM_Core_Error::debug_log_message("Ignoring exception thrown by nullHandler: {$obj->code}, {$obj->message}"); + CRM_Core_Error::debug_log_message("Ignoring exception thrown by nullHandler: {$obj->code}, {$obj->message}", FALSE, '', PEAR_LOG_ERR); CRM_Core_Error::backtrace('backTrace', TRUE); return $obj; }