Skip to content

Commit d0d4bef

Browse files
committed
fix(form): check hook before using it
1 parent b194a60 commit d0d4bef

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

inc/form.class.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,15 +2497,17 @@ public function canViewForRequest(): bool {
24972497
}
24982498

24992499
// Check plugins restrictions
2500-
foreach ($PLUGIN_HOOKS['formcreator_restrict_form'] as $plugin => $callable) {
2501-
// Skip if invalid hook
2502-
if (!is_callable($callable)) {
2503-
trigger_error("formcreator_restrict_form[$plugin]: not a callable", E_USER_WARNING);
2504-
continue;
2505-
}
2500+
if (isset($PLUGIN_HOOKS['formcreator_restrict_form'])) {
2501+
foreach ($PLUGIN_HOOKS['formcreator_restrict_form'] as $plugin => $callable) {
2502+
// Skip if invalid hook
2503+
if (!is_callable($callable)) {
2504+
trigger_error("formcreator_restrict_form[$plugin]: not a callable", E_USER_WARNING);
2505+
continue;
2506+
}
25062507

2507-
if (!call_user_func($callable, $this)) {
2508-
return false;
2508+
if (!call_user_func($callable, $this)) {
2509+
return false;
2510+
}
25092511
}
25102512
}
25112513

0 commit comments

Comments
 (0)