Skip to content

Commit

Permalink
fix(form): check hook before using it
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Apr 11, 2022
1 parent b194a60 commit d0d4bef
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2497,15 +2497,17 @@ public function canViewForRequest(): bool {
}

// Check plugins restrictions
foreach ($PLUGIN_HOOKS['formcreator_restrict_form'] as $plugin => $callable) {
// Skip if invalid hook
if (!is_callable($callable)) {
trigger_error("formcreator_restrict_form[$plugin]: not a callable", E_USER_WARNING);
continue;
}
if (isset($PLUGIN_HOOKS['formcreator_restrict_form'])) {
foreach ($PLUGIN_HOOKS['formcreator_restrict_form'] as $plugin => $callable) {
// Skip if invalid hook
if (!is_callable($callable)) {
trigger_error("formcreator_restrict_form[$plugin]: not a callable", E_USER_WARNING);
continue;
}

if (!call_user_func($callable, $this)) {
return false;
if (!call_user_func($callable, $this)) {
return false;
}
}
}

Expand Down

0 comments on commit d0d4bef

Please sign in to comment.