From: Tim Otten Date: Thu, 11 Dec 2014 00:10:00 +0000 (-0800) Subject: CRM-15683 - Add UnhandledExceptionEvent. Fixup LegacyErrorHandler. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4caeca046b149345ee52a24123605d2834a24476;p=civicrm-core.git CRM-15683 - Add UnhandledExceptionEvent. Fixup LegacyErrorHandler. --- diff --git a/CRM/Core/LegacyErrorHandler.php b/CRM/Core/LegacyErrorHandler.php index fff6d204bf..b10026ac6b 100644 --- a/CRM/Core/LegacyErrorHandler.php +++ b/CRM/Core/LegacyErrorHandler.php @@ -1,7 +1,12 @@ exception; if ($e instanceof CRM_Core_Exception) { $params = $e->getErrorData(); $message = $e->getMessage(); @@ -24,4 +29,5 @@ class CRM_Core_LegacyErrorHandler { } } } + } diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 6787614073..7e97befac0 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1459,12 +1459,18 @@ abstract class CRM_Utils_Hook { /** * @param CRM_Core_Exception Exception $exception + * @param mixed $request reserved for future use */ - static function unhandledException($exception) { - self::singleton()->invoke(1, $exception, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,'civicrm_unhandled_exception'); + static function unhandledException($exception, $request = NULL) { + self::singleton()->invoke(2, $exception, $request, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,'civicrm_unhandled_exception'); + // == 4.4 == + //$event = new stdClass(); + //$event->exception = $exception; + //CRM_Core_LegacyErrorHandler::handleException($event); + // == 4.5+ == - $event = new \Civi\Core\Event\UnhandledExceptionEvent(self::$_nullObject, $exception); - \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("unhandled_exception", $event); + $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject); + \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_unhandled_exception", $event); } /** diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 9db59203d9..4ee59208a9 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -96,7 +96,7 @@ class Container { $dispatcher->addListener('DAO::post-insert', array('\CRM_Core_BAO_RecurringEntity', 'triggerInsert')); $dispatcher->addListener('DAO::post-update', array('\CRM_Core_BAO_RecurringEntity', 'triggerUpdate')); $dispatcher->addListener('DAO::post-delete', array('\CRM_Core_BAO_RecurringEntity', 'triggerDelete')); - $dispatcher->addListener('hook_civicrm_unhandled_exception', array('CRM_Core_LegacyErrorHandler', 'handleException'); + $dispatcher->addListener('hook_civicrm_unhandled_exception', array('CRM_Core_LegacyErrorHandler', 'handleException')); return $dispatcher; } diff --git a/Civi/Core/Event/UnhandledExceptionEvent.php b/Civi/Core/Event/UnhandledExceptionEvent.php new file mode 100644 index 0000000000..f2f5b4528e --- /dev/null +++ b/Civi/Core/Event/UnhandledExceptionEvent.php @@ -0,0 +1,50 @@ +request = $request; + $this->exception = $e; + } +}