Webtest Fix 4.5
[civicrm-core.git] / CRM / Core / Error.php
index 05ec54b7878dd59800b624d4b8f171f82123011e..8cddeac76de4fd4368373875500b3ab30e730bdc 100644 (file)
@@ -57,9 +57,13 @@ class CRM_Exception extends PEAR_Exception {
    *  - 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 exception message
-   * @param int|Exception|PEAR_Error|array|null exception cause
-   * @param int|null exception code or null
+   * @param int $code
+   * @param Exception $previous
+   *
+   * @internal param array|\Exception|int|null|\PEAR_Error $exception cause
+   * @internal param int|null $exception code or null
    */
   public function __construct($message = NULL, $code = 0, Exception$previous = NULL) {
     parent::__construct($message, $code, $previous);
@@ -121,7 +125,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
   }
 
   /**
-   * construcor
+   * constructor
    */
   function __construct() {
     parent::__construct('CiviCRM');
@@ -381,19 +385,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
 
     CRM_Core_Error::debug_var('Fatal Error Details', $vars);
     CRM_Core_Error::backtrace('backTrace', TRUE);
-    $content = $template->fetch($config->fatalErrorTemplate);
-    // JErrorPage exists only in 3.x and not 2.x
-    // CRM-13714
-    if ($config->userFramework == 'Joomla' && class_exists('JErrorPage')) {
-      $error = new Exception($content);
-      JErrorPage::render($error);
-    }
-    else if ($config->userFramework == 'Joomla' && class_exists('JError')) {
-      JError::raiseError('CiviCRM-001', $content);
-    }
-    else {
-      echo CRM_Utils_System::theme($content);
-    }
+    $config->userSystem->outputError($template->fetch($config->fatalErrorTemplate));
 
     self::abend(CRM_Core_Error::FATAL_ERROR);
   }
@@ -599,6 +591,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
     $file_log->close();
 
     if ($config->userFrameworkLogging) {
+      // should call $config->userSystem->logger($message) here - but I got a situation where userSystem was not an object - not sure why
       if ($config->userSystem->is_drupal and function_exists('watchdog')) {
         watchdog('civicrm', $message, NULL, WATCHDOG_DEBUG);
       }
@@ -834,12 +827,15 @@ class CRM_Core_Error extends PEAR_ErrorStack {
    * @access public
    * @static
    */
-  public static function statusBounce($status, $redirect = NULL, $title = '') {
+  public static function statusBounce($status, $redirect = NULL, $title = NULL) {
     $session = CRM_Core_Session::singleton();
     if (!$redirect) {
       $redirect = $session->readUserContext();
     }
-    $session->setStatus($status, $title);
+    if ($title === NULL) {
+      $title = ts('Error');
+    }
+    $session->setStatus($status, $title, 'alert', array('expires' => 0));
     if (CRM_Utils_Array::value('snippet', $_REQUEST) === CRM_Core_Smarty::PRINT_JSON) {
       CRM_Core_Page_AJAX::returnJsonResponse(array('status' => 'error'));
     }