Skip to content

Commit

Permalink
[BUGFIX] Return buttons if page is not callable
Browse files Browse the repository at this point in the history
The ButtonBarHook seems to be called on root (pid=0) or other possible
constellations, too. In these cases (and some other) the BackendUtility
can't return avalid page record and returns null instead. Following up
code didn't check, if a valid page record was loaded from the database,
which lead to errors. WIth this commit, a check on a `$page === null`
and hardening on possible not set array keys is added avoiding this issue
  • Loading branch information
calien666 committed Nov 20, 2024
1 parent dc4c314 commit 2ef7f75
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Classes/Hooks/ButtonBarHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ public function getButtons(array $params, ButtonBar $buttonBar): array
return $buttons;
}

/** @var array{uid: int, doktype: int, module: string} $page */
/** @var array{uid: int, doktype?: int, module?: string}|null $page */
$page = BackendUtility::getRecord(
'pages',
$queryParams['id'],
'uid,module,doktype'
);

if (
(int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER
|| $page['module'] !== 'glossary'
$page === null
|| (int)($page['doktype'] ?? 0) !== PageRepository::DOKTYPE_SYSFOLDER
|| ($page['module'] ?? '') !== 'glossary'
) {
return $buttons;
}
Expand Down

0 comments on commit 2ef7f75

Please sign in to comment.