From e3a0591f88f949e033badb2f110ae97d69aee3d7 Mon Sep 17 00:00:00 2001 From: sdelcroix Date: Thu, 14 Sep 2023 22:05:29 +0200 Subject: [PATCH 1/2] Fixes Uncaught TYPO3 Exception: in Hooks\AbstractBeButtons::generateButtons() if _GP('id') is null --- Classes/Hooks/DocHeaderButtonsHook.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Classes/Hooks/DocHeaderButtonsHook.php b/Classes/Hooks/DocHeaderButtonsHook.php index 8923fa1..ae27f31 100644 --- a/Classes/Hooks/DocHeaderButtonsHook.php +++ b/Classes/Hooks/DocHeaderButtonsHook.php @@ -62,6 +62,8 @@ public function getButtons(array $params, ButtonBar $buttonBar): array { $buttons = $params['buttons']; + if(is_null(GeneralUtility::_GP('id'))) return $buttons; + foreach ($this->generateButtons(GeneralUtility::_GP('id')) as $buttonInfo) { $button = $buttonBar->makeLinkButton(); $button->setIcon($buttonInfo['icon']); From b9e9df0387fd594a5e75136918d33bbd2ee3c263 Mon Sep 17 00:00:00 2001 From: sdelcroix Date: Sat, 16 Sep 2023 01:09:29 +0200 Subject: [PATCH 2/2] Replace deprecated GU::_GP() with Request --- Classes/Hooks/DocHeaderButtonsHook.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Classes/Hooks/DocHeaderButtonsHook.php b/Classes/Hooks/DocHeaderButtonsHook.php index ae27f31..60e1be6 100644 --- a/Classes/Hooks/DocHeaderButtonsHook.php +++ b/Classes/Hooks/DocHeaderButtonsHook.php @@ -27,6 +27,7 @@ namespace BeechIt\FalSecuredownload\Hooks; +use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UriInterface; use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; use TYPO3\CMS\Backend\Template\Components\ButtonBar; @@ -62,9 +63,10 @@ public function getButtons(array $params, ButtonBar $buttonBar): array { $buttons = $params['buttons']; - if(is_null(GeneralUtility::_GP('id'))) return $buttons; + $identifier = $this->getRequest()->getQueryParams()['id'] ?? null; + if(is_null($identifier)) return $buttons; - foreach ($this->generateButtons(GeneralUtility::_GP('id')) as $buttonInfo) { + foreach ($this->generateButtons($identifier) as $buttonInfo) { $button = $buttonBar->makeLinkButton(); $button->setIcon($buttonInfo['icon']); $button->setTitle($buttonInfo['title']); @@ -74,4 +76,12 @@ public function getButtons(array $params, ButtonBar $buttonBar): array return $buttons; } + + /** + * Get Request + */ + private function getRequest(): ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST']; + } }