From 63726893cb955dd7f121ca7d7890310360ad49d2 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 22 Sep 2010 17:01:39 +0200 Subject: [PATCH] Add warnings. Throwing exceptions is expensive!!! --- framework/Core/lib/Horde.php | 6 +++++- horde/docs/CODING_STANDARDS | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 901991d14..d60053730 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -1667,6 +1667,9 @@ HTML; * Call a Horde hook, handling all of the necessary lookups and parsing * of the hook code. * + * WARNING: Throwing exceptions is expensive, so use callHook() with care + * and cache the results if you going to use the results more than once. + * * @param string $hook The function to call. * @param array $args An array of any arguments to pass to the hook * function. @@ -1681,7 +1684,8 @@ HTML; $error = false; $hook_class = $app . '_Hooks'; - if (empty(self::$_hooksLoaded[$app]) && !class_exists($hook_class, false)) { + if (empty(self::$_hooksLoaded[$app]) && + !class_exists($hook_class, false)) { try { self::loadConfiguration('hooks.php', null, $app); } catch (Horde_Exception $e) {} diff --git a/horde/docs/CODING_STANDARDS b/horde/docs/CODING_STANDARDS index 40733e17a..80126ddda 100644 --- a/horde/docs/CODING_STANDARDS +++ b/horde/docs/CODING_STANDARDS @@ -617,6 +617,10 @@ to a Horde_Exception before throwing. When throwing a Horde_Exception the error message provided should not be localized. +Throwing exceptions is expensive, so use them carefully for logic flow. You +should cache results of Horde::callHook() calls for example, if you expect them +to not exist. + Existence checking ================== -- 2.11.0