Merge pull request #1964 from dlobo/CRM-13746
[civicrm-core.git] / CRM / Core / Error.php
index d7734e0abcc85c268b5547a10c491767d11f1da2..b32da1445f42aae4912377af7ab1145b07ba6e23 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -204,7 +204,11 @@ class CRM_Core_Error extends PEAR_ErrorStack {
       echo "Sorry. A non-recoverable error has occurred. The error trace below might help to resolve the issue<p>";
       CRM_Core_Error::debug(NULL, $error);
     }
-
+    static $runOnce = FALSE;
+    if ($runOnce) {
+      exit;
+    }
+    $runOnce = TRUE;
     self::abend(1);
   }
 
@@ -315,8 +319,16 @@ 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);
-    if ($config->userFramework == 'Joomla' && class_exists('JError')) {
-      JError::raiseError('CiviCRM-001', $content);
+    if ($config->userFramework == 'Joomla') {
+      // JErrorPage exists only in 3.1.x
+      // a bit ugly hack, but want this in for 4.4.1
+      // CRM-13714
+      if (class_exists('JError') && !class_exists('JErrorPage')) {
+        JError::raiseError('CiviCRM-001', $content);
+      }
+      else {
+        echo CRM_Utils_System::theme($content);
+      }
     }
     else {
       echo CRM_Utils_System::theme($content);