FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
190 stars 229 forks source link

[BUG] AbstractMenuViewHelper->determineParentPageUid fails with PHP 8 on root level #1845

Closed Bunnyfield closed 11 months ago

Bunnyfield commented 1 year ago

When using with levels and entryLevel set only but wihtout a given pageUid the ViewHelper fails with one of the following error messages in PHP 8.x on root level pages:

Core: Error handler (FE): PHP Warning: Trying to access array offset on value of type null in /var/www/html/public/typo3conf/ext/vhs/Classes/ViewHelpers/Menu/AbstractMenuViewHelper.php line 404

Core: Error handler (FE): PHP Warning: Undefined array key 1 in /var/www/html/public/typo3conf/ext/vhs/Classes/ViewHelpers/Menu/AbstractMenuViewHelper.php line 404

Reason is that

$pageUid = $rootLineData[$entryLevel]['uid'];

can only work, if

  1. $rootLineData is an array
  2. the array key $entryLevel exists

So there should be a check for both.

NamelessCoder commented 11 months ago

Thanks @Bunnyfield, good catch!