diff options
-rw-r--r-- | includes/module.inc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/includes/module.inc b/includes/module.inc index ffdb4c165..3e8d5339b 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -384,9 +384,15 @@ function module_hook($module, $hook) { * the implementations are loaded as necessary. */ function module_implements($hook, $sort = FALSE) { - static $implementations = array(), $sorted_implementations = array(), $loaded = array(), $cached_hooks = 0; + static $implementations = array(), $sorted_implementations = array(), $loaded = array(), $cached_hooks = 0, $maintenance; - if (defined('MAINTENANCE_MODE')) { + // Use a static variable for maintenance mode to avoid the overhead of + // calling defined() each time the function is called. + if (!isset($maintenance)) { + $maintenance = defined('MAINTENANCE_MODE'); + } + + if ($maintenance) { return _module_implements_maintenance($hook, $sort); } if ($hook === MODULE_IMPLEMENTS_CLEAR_CACHE) { |