From 2ef7f7583988b8f7272fea0bdc10c69ecf921cd4 Mon Sep 17 00:00:00 2001 From: mhofmann Date: Wed, 20 Nov 2024 19:16:03 +0100 Subject: [PATCH] [BUGFIX] Return buttons if page is not callable 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 --- Classes/Hooks/ButtonBarHook.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Classes/Hooks/ButtonBarHook.php b/Classes/Hooks/ButtonBarHook.php index 16ec516..f65b71f 100644 --- a/Classes/Hooks/ButtonBarHook.php +++ b/Classes/Hooks/ButtonBarHook.php @@ -34,7 +34,7 @@ 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'], @@ -42,8 +42,9 @@ public function getButtons(array $params, ButtonBar $buttonBar): array ); if ( - (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER - || $page['module'] !== 'glossary' + $page === null + || (int)($page['doktype'] ?? 0) !== PageRepository::DOKTYPE_SYSFOLDER + || ($page['module'] ?? '') !== 'glossary' ) { return $buttons; }