CRM_Core_Error::debug_var('Fatal Error Details', $error, TRUE, TRUE, '', PEAR_LOG_ERR);
CRM_Core_Error::backtrace('backTrace', TRUE);
+ $exit = TRUE;
if ($config->initialized) {
$content = $template->fetch('CRM/common/fatal.tpl');
echo CRM_Utils_System::theme($content);
+ $exit = CRM_Utils_System::exitAfterFatal();
}
else {
echo "Sorry. A non-recoverable error has occurred. The error trace below might help to resolve the issue<p>";
exit;
}
$runOnce = TRUE;
- self::abend(CRM_Core_Error::FATAL_ERROR);
+ self::abend(CRM_Core_Error::FATAL_ERROR, $exit);
}
/**
}
echo CRM_Utils_System::theme($content);
+ $exit = CRM_Utils_System::exitAfterFatal();
// fin
- self::abend(CRM_Core_Error::FATAL_ERROR);
+ self::abend(CRM_Core_Error::FATAL_ERROR, $exit);
}
/**
* Terminate execution abnormally.
*
* @param string $code
+ * @param bool $exit
*/
- protected static function abend($code) {
+ protected static function abend($code, $exit = TRUE) {
// do a hard rollback of any pending transactions
// if we've come here, its because of some unexpected PEAR errors
CRM_Core_Transaction::forceRollbackIfEnabled();
- CRM_Utils_System::civiExit($code);
+ if ($exit) {
+ CRM_Utils_System::civiExit($code);
+ }
}
/**
* @method static array synchronizeUsers() Create CRM contacts for all existing CMS users.
* @method static void appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_coreResourceList.
* @method static void alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_getAssetUrl.
+ * @method static exitAfterFatal() Should the current execution exit after a fatal error?
*/
class CRM_Utils_System {
*/
public function permissionDenied() {
status_header(403);
+ global $civicrm_wp_title;
+ $civicrm_wp_title = ts('You do not have permission to access this page.');
throw new CRM_Core_Exception(ts('You do not have permission to access this page.'));
}
return !$this->isUserRegistrationPermitted();
}
+ /**
+ * Should the current execution exit after a fatal error?
+ *
+ * In WordPress, it is not usually possible to trigger theming outside of the WordPress theme process,
+ * meaning that in order to render an error inside the theme we cannot exit on error.
+ *
+ * @return bool
+ */
+ public function exitAfterFatal() {
+ $ret = TRUE;
+ if (!is_admin() && !wp_doing_ajax()) {
+ $ret = FALSE;
+ }
+
+ return apply_filters('civicrm_exit_after_fatal', $ret);
+ }
+
}