From 0a5841702fdc6e71f23b7eebd046ef715b74b544 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 29 Jan 2015 12:41:43 -0500
Subject: [PATCH] Fix exec_hook() so handlers added inside the hook are not omitted

---
 program/lib/Roundcube/rcube_plugin_api.php |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php
index 346e832..b3a3298 100644
--- a/program/lib/Roundcube/rcube_plugin_api.php
+++ b/program/lib/Roundcube/rcube_plugin_api.php
@@ -400,8 +400,9 @@
         $args += array('abort' => false);
         array_push($this->exec_stack, $hook);
 
-        foreach ((array)$this->handlers[$hook] as $callback) {
-            $ret = call_user_func($callback, $args);
+        // Use for loop here, so handlers added in the hook will be executed too
+        for ($i = 0; $i < count($this->handlers[$hook]); $i++) {
+            $ret = call_user_func($this->handlers[$hook][$i], $args);
             if ($ret && is_array($ret)) {
                 $args = $ret + $args;
             }

--
Gitblit v1.9.1