From 13d18376c1a648b686410db0bcfab0e3a5af6429 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 14 Aug 2013 19:14:16 -0700 Subject: [PATCH] Log and continue when trying to register an invalid event listener Summary: We currently die if an event listener throws when registering (e.g., because it is misconfigured), but this prevents you from running `bin/config` to fix it, which is a bit silly. Test Plan: Created this revision with an invalid listener in config. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6761 --- src/infrastructure/events/PhabricatorEventEngine.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/events/PhabricatorEventEngine.php b/src/infrastructure/events/PhabricatorEventEngine.php index 2f14a2d1e7..8d49752d61 100644 --- a/src/infrastructure/events/PhabricatorEventEngine.php +++ b/src/infrastructure/events/PhabricatorEventEngine.php @@ -8,7 +8,14 @@ final class PhabricatorEventEngine { public static function initialize() { $listeners = PhabricatorEnv::getEnvConfig('events.listeners'); foreach ($listeners as $listener) { - id(new $listener())->register(); + try { + id(new $listener())->register(); + } catch (Exception $ex) { + // If the listener does not exist, or throws when registering, just + // log it and continue. In particular, this is important to let you + // run `bin/config` in order to remove an invalid listener. + phlog($ex); + } } // Register the DarkConosole event logger.