Issue Bug Closed

#89148Media viewhelper empty additionalConfig causes php warning

Jarvis H 09/11/19, 12:27 updated 04/01/20, 21:14

Description

Typo3 version 9.5.9

Error message:

PHP Warning: array_merge_recursive(): Argument #2 is not an array in /typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php line 119

How to reproduce.

Remove typoscript setting:

lib.contentElement.settings.media.additionalConfig >

or remove value from additionalConfig argument in fluid partial FluidStyledContent/Partials/Media/Rendering/Video.html

<f:media file="{file}" class="{class}" additionalAttributes="" alt="{file.alternative}" title="{file.title}" additionalConfig="" />

Cause:

In TYPO3\CMS\Fluid\ViewHelpers\MediaViewHelper the following takes place without checking if $additionalConfig is an array

$additionalConfig = array_merge_recursive($this->arguments, $additionalConfig);

Possible solution:

Add is_array check:

if (!is_array($additionalConfig)) {
    $additionalConfig = [];
}

$additionalConfig = array_merge_recursive($this->arguments, $additionalConfig);

Reviews 2