FluidTYPO3 / vhs

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

PHP 8 warning exception due to missing array keys: Undefined array key "params" #1803

Closed tomashavner closed 1 year ago

tomashavner commented 1 year ago

Hi,

In ext/vhs/Classes/ViewHelpers/Media/SourceViewHelper.php there is a missing key array in line 136. Adding a params key to the setup array fixes this (line 119 ff): $setup = [ 'width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'minW' => $this->arguments['minW'], 'minH' => $this->arguments['minH'], 'maxW' => $this->arguments['maxW'], 'maxH' => $this->arguments['maxH'], 'treatIdAsReference' => $treatIdAsRerefence, 'params' => null ];

Kind regards

Tomas

javagotchi commented 1 year ago

same here:

PHP Warning: Undefined array key "tt_content:576" in /typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 222

Skywalker-11 commented 1 year ago

Changing line 222 from if (0 < $GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']]) { to if (0 < ($GLOBALS['TSFE']->recordRegister['tt_content:' . $row['uid']] ?? 0)) { seems to fix it for me

j0nnybrav079 commented 1 year ago

why not just if (array_key_exists('tt_content:' . $row['uid'], $GLOBALS['TSFE']->recordRegister)) { ?

Skywalker-11 commented 1 year ago

why not just if (array_key_exists('tt_content:' . $row['uid'], $GLOBALS['TSFE']->recordRegister)) { ?

I don't know the details of the vhs implementation but assumed having 0 or negative values might have a special meaning which would not be covered with your if statement alone.

NamelessCoder commented 1 year ago

Fixed via https://github.com/FluidTYPO3/vhs/commit/99e05be074c03e10a6ef2f9c244f805d8d9d8b8f#diff-0204d72a43461de588cbf25b096822c3133ee7143540efd05241eaa9172460ff (originally reported issue).

Issue from comments is dupe of https://github.com/FluidTYPO3/vhs/issues/1787.