From 3ab58ffe5551d68e5a34f8e29e55c5e0c2511570 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 17 Apr 2012 09:46:23 +0200 Subject: no need to pass objects by reference fixes passing null to event hook registration --- inc/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/events.php') diff --git a/inc/events.php b/inc/events.php index 621cb64c1..09f3f3c0c 100644 --- a/inc/events.php +++ b/inc/events.php @@ -149,8 +149,8 @@ class Doku_Event_Handler { * @param $method (function) event handler function * @param $param (mixed) data passed to the event handler */ - function register_hook($event, $advise, &$obj, $method, $param=null) { - $this->_hooks[$event.'_'.$advise][] = array(&$obj, $method, $param); + function register_hook($event, $advise, $obj, $method, $param=null) { + $this->_hooks[$event.'_'.$advise][] = array($obj, $method, $param); } function process_event(&$event,$advise='') { -- cgit v1.2.3 From 8cb3706df5ad54c654bffb76a69ac0ca1006521e Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 11 May 2012 10:33:15 +0200 Subject: 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. --- inc/events.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/events.php') diff --git a/inc/events.php b/inc/events.php index 09f3f3c0c..4e81f85c8 100644 --- a/inc/events.php +++ b/inc/events.php @@ -158,8 +158,7 @@ class Doku_Event_Handler { $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 @@ class Doku_Event_Handler { $obj->$method($event, $param); } - } while ($event->_continue && $hook = next($this->_hooks[$evt_name])); + if (!$event->_continue) break; + } } } } -- cgit v1.2.3