Permalink
Browse files

Fix nested triggering of the same event

Previously when in an event handler the same event was triggered again,
only the handlers for the second event invocation were all executed, the
handling of the "outer" event stopped after the handling of the inner
event as they both used the same iterator of the hooks array. This
caused caching bugs e.g. when both the include and the indexmenu plugin
were enabled as both of them load metadata in the cache handler which
triggers another renderer cache event.
  • Loading branch information...
michitux committed May 11, 2012
1 parent 2daedc0 commit 8cb3706df5ad54c654bffb76a69ac0ca1006521e
Showing with 3 additions and 3 deletions.
  1. +3 −3 inc/events.php
View
@@ -158,8 +158,7 @@ function process_event(&$event,$advise='') {
$evt_name = $event->name . ($advise ? '_'.$advise : '_BEFORE');
if (!empty($this->_hooks[$evt_name])) {
- $hook = reset($this->_hooks[$evt_name]);
- do {
+ foreach ($this->_hooks[$evt_name] as $hook) {
// list($obj, $method, $param) = $hook;
$obj =& $hook[0];
$method = $hook[1];
@@ -171,7 +170,8 @@ function process_event(&$event,$advise='') {
$obj->$method($event, $param);
}
- } while ($event->_continue && $hook = next($this->_hooks[$evt_name]));
+ if (!$event->_continue) break;
+ }
}
}
}

2 comments on commit 8cb3706

Owner

splitbrain replied May 11, 2012

Could you please provide a unit test for this?

Collaborator

michitux replied Jun 30, 2012

Done in 772c924

Please sign in to comment.