beechit / fal_securedownload

An extension for TYPO3 CMS which adds secure downloads to FAL
36 stars 62 forks source link

Uncaught TYPO3 Exception: BeechIt\FalSecuredownload\Hooks\AbstractBeButtons::generateButtons() #217

Closed mbsued closed 1 year ago

mbsued commented 1 year ago

With Typo3 Version 11.5.31, php 8.1-latest FPM (8.1.18) (P+) and fal_securdownload 5.0.0 Typo3 throws the following error:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: BeechIt\FalSecuredownload\Hooks\AbstractBeButtons::generateButtons(): Argument #1 ($combinedIdentifier) must be of type string, null given, called in /html/typo3/typo3conf/ext/fal_securedownload/Classes/Hooks/DocHeaderButtonsHook.php on line 65 | TypeError thrown in file /html/typo3/typo3conf/ext/fal_securedownload/Classes/Hooks/AbstractBeButtons.php in line 61.

stephangrass commented 1 year ago

Same error here.

joey-bolts commented 1 year ago

Thanks for the ticket.

I might be able to look into this tomorrow or starting next week. Any PR would speed up a fix.

sdelcroix commented 1 year ago

I confirm this issue with TYPO3 11.5.30, PHP 7.4 FPM and fal_securedownload 5.0.0

sdelcroix commented 1 year ago

It is caused by string type hint for $combinedIdentifier argument in BeechIt\FalSecuredownload\Hooks\AbstractBeButtons::generateButtons() added with 5.0.0 version.

A quick fix could be in Hooks/DocHeaderButtonsHook::getButtons() :

  public function getButtons(array $params, ButtonBar $buttonBar): array
    {
        $buttons = $params['buttons'];

        if(is_null(GeneralUtility::_GP('id'))) return $buttons; // HERE THE QUICK FIX

        foreach ($this->generateButtons(GeneralUtility::_GP('id')) as $buttonInfo) {
            $button = $buttonBar->makeLinkButton();
            $button->setIcon($buttonInfo['icon']);
            $button->setTitle($buttonInfo['title']);
            $button->setHref($buttonInfo['url']);
            $buttons[ButtonBar::BUTTON_POSITION_LEFT][1][] = $button;
        }

        return $buttons;
    }