Skip to content
This repository
Browse code

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...
commit 8cb3706df5ad54c654bffb76a69ac0ca1006521e 1 parent 2daedc0
Michael Hamann authored May 11, 2012

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. 6  inc/events.php
6  inc/events.php
@@ -158,8 +158,7 @@ function process_event(&$event,$advise='') {
158 158
         $evt_name = $event->name . ($advise ? '_'.$advise : '_BEFORE');
159 159
 
160 160
         if (!empty($this->_hooks[$evt_name])) {
161  
-            $hook = reset($this->_hooks[$evt_name]);
162  
-            do {
  161
+            foreach ($this->_hooks[$evt_name] as $hook) {
163 162
                 //        list($obj, $method, $param) = $hook;
164 163
                 $obj =& $hook[0];
165 164
                 $method = $hook[1];
@@ -171,7 +170,8 @@ function process_event(&$event,$advise='') {
171 170
                     $obj->$method($event, $param);
172 171
                 }
173 172
 
174  
-            } while ($event->_continue && $hook = next($this->_hooks[$evt_name]));
  173
+                if (!$event->_continue) break;
  174
+            }
175 175
         }
176 176
     }
177 177
 }

2 notes on commit 8cb3706

Andreas Gohr
Owner

Could you please provide a unit test for this?

Michael Hamann
Collaborator

Done in 772c924

Please sign in to comment.
Something went wrong with that request. Please try again.