Thanks for the feedback. A couple of things to note:
- This issue only occurs on the first page load after changing the additionalConfig
attribute in the video partial to additionalConfig="{}"
- The issue occurs every time if additionalConfig=""
I suspect your error for argument 4 in VideoTagRenderer
is caused by the same underlying issue which is causing the php warning in the array_merge_recursive
call.
As far as I can tell the issue arises because the value of the argument additionalConfig
is set to null on the first page load and I traced it back to the ViewHelperInvoker class (vendor/typo3fluid/fluid/src/Core/ViewHelper/ViewHelperInvoker.php).
In the main invoke
method, the following happens when additionalConfig="{}"
is used (see my inline comments for clarification):
try {
foreach ($expectedViewHelperArguments as $argumentName => $argumentDefinition) {
if (isset($arguments[$argumentName])) {
/** @var NodeInterface|mixed $argumentValue */
$argumentValue = $arguments[$argumentName];
$evaluatedArguments[$argumentName] = $argumentValue instanceof NodeInterface ? $argumentValue->evaluate($renderingContext) : $argumentValue;
// --------------------------------------------------
// After deleting system caches and loading page '$evaluatedArguments[$argumentName]' equals null
// as $argumentValue is an instance of \TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode
// where the property 'childNodes' is empty causing '$argumentValue->evaluate($renderingContext)' to return null
if ($argumentName == 'additionalConfig') {
\TYPO3\CMS\Core\Utility\DebugUtility::debug($evaluatedArguments[$argumentName]);
}
// --------------------------------------------------
} else {
// --------------------------------------------------
// After loading page again '$evaluatedArguments[$argumentName]'
// returns an empty array as it should
$evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue();
if ($argumentName == 'additionalConfig') {
\TYPO3\CMS\Core\Utility\DebugUtility::debug($evaluatedArguments[$argumentName]);
}
// --------------------------------------------------
}
}
foreach ($arguments as $argumentName => $argumentValue) {
if (!array_key_exists($argumentName, $evaluatedArguments)) {
$undeclaredArguments[$argumentName] = $argumentValue instanceof NodeInterface ? $argumentValue->evaluate($renderingContext) : $argumentValue;
}
}
if ($renderChildrenClosure) {
$viewHelper->setRenderChildrenClosure($renderChildrenClosure);
}
$viewHelper->setRenderingContext($renderingContext);
// --------------------------------------------------
// Here the arguments property is set for the MediaViewHelper
$viewHelper->setArguments($evaluatedArguments);
// --------------------------------------------------
$viewHelper->handleAdditionalArguments($undeclaredArguments);
return $viewHelper->initializeArgumentsAndRender();
} catch (Exception $error) {
return $renderingContext->getErrorHandler()->handleViewHelperError($error);
}
However this only adds to my confusion, as I am guessing it has something to do with the fluid caching mechanism.
Edit: The question is, what would be the expected behaviour when passing either an empty string or empty array to an argument which defaults to an array? InvalidTypeException
for an empty string and no warning at all for an empty array?