lochmueller / calendarize

šŸ“† Best TYPO3 Calendar ever šŸ“†
http://typo3.org/extensions/repository/view/calendarize
74 stars 84 forks source link

CalendarController not applying settings in pastAction() #795

Closed maelstromer closed 6 months ago

maelstromer commented 6 months ago

While implementing the most recent version in a client's website, which I am upgrading to TYPO3 v12, I encountered a bug that occurs in the pastAction of the CalendarController.

To be more precise, in HDNET\Calendarize\Controller\CalendarController:282 & 283 the following lines of code contain an error:

$limit = $limit ?: (int)($this->settings['limit']);
$sort = $sort ?: $this->settings['sorting'];

Both variables $limit & $sort are prepopulated with default values beforehand and then these lines check whether $this->settings['limit'] and $this->settings['sorting'] contain custom values to use, instead of the default ones.

However, in the current state these custom values will not be applied, because the ternary shorthand (?:) will evaluate to the first argument, which is not 'false', which will always be the default value.

Consequently, these arguments need to be switched around for them to work correctly, looking more like this:

$limit = (int)($this->settings['limit']) ?: $limit;
$sort = $this->settings['sorting'] ?: $sort;
lochmueller commented 6 months ago

Hey @maelstromer thanks for reporting. Fixed in current main branch. Regards, Tim

maelstromer commented 6 months ago

Thanks for the quick response! Have a good one!