From 0b7110504e6e7557b025ff274ca942d1562f13ee Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 2 Apr 2011 19:01:14 +0000 Subject: Refs #3149 reimplemented fix for calling a handler more than once in trunk git-svn-id: http://code.elgg.org/elgg/trunk@8918 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 87866f318..1aef48ef4 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -889,6 +889,12 @@ function elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback) { * called for all hooks of type $event, regardless of $object_type. If $hook * and $type both are 'all', the handler will be called for all hooks. * + * @internal The checks for $hook and/or $type not being equal to 'all' is to + * prevent a plugin hook being registered with an 'all' being called more than + * once if the trigger occurs with an 'all'. An example in core of this is in + * actions.php: + * elgg_trigger_plugin_hook('action_gatekeeper:permissions:check', 'all', ...) + * * @see elgg_register_plugin_hook_handler() * * @param string $hook The name of the hook to trigger ("all" will @@ -914,13 +920,19 @@ function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = n $hooks = array(); if (isset($CONFIG->hooks[$hook][$type])) { - $hooks[] = $CONFIG->hooks[$hook][$type]; + if ($hook != 'all' && $type != 'all') { + $hooks[] = $CONFIG->hooks[$hook][$type]; + } } if (isset($CONFIG->hooks['all'][$type])) { - $hooks[] = $CONFIG->hooks['all'][$type]; + if ($type != 'all') { + $hooks[] = $CONFIG->hooks['all'][$type]; + } } if (isset($CONFIG->hooks[$hook]['all'])) { - $hooks[] = $CONFIG->hooks[$hook]['all']; + if ($hook != 'all') { + $hooks[] = $CONFIG->hooks[$hook]['all']; + } } if (isset($CONFIG->hooks['all']['all'])) { $hooks[] = $CONFIG->hooks['all']['all']; -- cgit v1.2.3