]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #3149 reimplemented fix for calling a handler more than once in trunk
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 2 Apr 2011 19:01:14 +0000 (19:01 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 2 Apr 2011 19:01:14 +0000 (19:01 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8918 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php

index 87866f3182b947e14c5fb00f1f6cf7803cef6a4f..1aef48ef468129544a7f0d9246a2220adf1e8745 100644 (file)
@@ -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'];