From 6cadf82a637b522ae852f63ac9f7b56bbdaa1a16 Mon Sep 17 00:00:00 2001 From: Alex Watson Date: Sun, 21 Feb 2021 23:15:58 -0500 Subject: [PATCH] Fixing variables being shared between plugins If two plugins used the same hook, the variables they use aren't cleaned out in between running each of them. This is a super simple change creating a placeholder composite object that doesn't retain any changes between plugins. --- app/Helper/HookHelper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Helper/HookHelper.php b/app/Helper/HookHelper.php index 24b7d00a8..76d255ca9 100644 --- a/app/Helper/HookHelper.php +++ b/app/Helper/HookHelper.php @@ -45,17 +45,18 @@ class HookHelper extends Base $buffer = ''; foreach ($this->hook->getListeners($hook) as $params) { + $currentVariables = $variables; if (! empty($params['variables'])) { - $variables = array_merge($variables, $params['variables']); + $currentVariables = array_merge($variables, $params['variables']); } elseif (! empty($params['callable'])) { $result = call_user_func_array($params['callable'], $variables); if (is_array($result)) { - $variables = array_merge($variables, $result); + $currentVariables = array_merge($variables, $result); } } - $buffer .= $this->template->render($params['template'], $variables); + $buffer .= $this->template->render($params['template'], $currentVariables); } return $buffer;