aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-02 19:01:14 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-02 19:01:14 +0000
commit0b7110504e6e7557b025ff274ca942d1562f13ee (patch)
treeb84d945b75882ad1282090e84969e25377cda909 /engine/lib
parent6db26c7a915b873a17197bbca7d7c5cbd88b744e (diff)
downloadelgg-0b7110504e6e7557b025ff274ca942d1562f13ee.tar.gz
elgg-0b7110504e6e7557b025ff274ca942d1562f13ee.tar.bz2
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
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/elgglib.php18
1 files changed, 15 insertions, 3 deletions
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'];