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.
This commit is contained in:
Alex Watson 2021-02-21 23:15:58 -05:00 committed by GitHub
parent 7e2598cedb
commit 6cadf82a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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;