lochmueller / calendarize

📆 Best TYPO3 Calendar ever 📆
http://typo3.org/extensions/repository/view/calendarize
75 stars 84 forks source link

Rendering of link target fails when pageUid is null #796

Closed maelstromer closed 3 months ago

maelstromer commented 3 months ago

Hi again,

I have encountered another minor bug in calendarize v13.0.3.

In HDNET\Calendarize\ViewHelpers\Link\ListViewHelper.php:31 the process failed and threw an exception, because the call to $this->getPageUid() received NULL as value für the first parameter $this->arguments['pageUid'], while the AbstrachtLinkViewHelper containing the function getPageUid() now requires the first parameter $pageUid to be of type integer.

As an easy fix, I provided the first argument in the call to the function with a null-coalescing operator, defaulting to int 0:

public function render()
{
    return $this->renderExtbaseLink([], $this->getPageUid($this->arguments['pageUid'] ?? 0, 'listPid'));
}

I felt this approach to be cleaner than typecasting the argument or removing the type requirement from the abstract class again.

This should help with the compatibility to PHP 8.2.

lochmueller commented 3 months ago

Hey @maelstromer , thanks for reporting. I moved the argument resolving to the parent method in this commit https://github.com/lochmueller/calendarize/commit/9c34c444f512147b98271a89db93dcf8cf5892b5 Regards, Tim