diff --git a/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php b/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php index 3ffeb0bba596dfc57881eb5c91b72204b03eb5aa..0c336214f4912e76422dc1c77ba7161658664586 100644 --- a/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php +++ b/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php @@ -305,9 +305,8 @@ class TypoScriptParser $tsFunc = $match[1]; $tsFuncArg = $match[2]; $val = $this->getVal($objStrName, $setup); - $currentValue = $val[0] ?? null; $tsFuncArg = str_replace(['\\\\', '\\n', '\\t'], ['\\', LF, "\t"], $tsFuncArg); - $newValue = $this->executeValueModifier($tsFunc, $tsFuncArg, $currentValue); + $newValue = $this->executeValueModifier($tsFunc, $tsFuncArg, $val[0]); if (isset($newValue)) { $line = '= ' . $newValue; } @@ -363,6 +362,12 @@ class TypoScriptParser } else { $res = $this->getVal($theVal, $this->setup); } + if ($res[0] === '') { + unset($res[0]); + } + if ($res[1] === []) { + unset($res[1]); + } // unserialize(serialize(...)) may look stupid but is needed because of some reference issues. // See forge issue #76919 and functional test hasFlakyReferences() $this->setVal($objStrName, $setup, unserialize(serialize($res), ['allowed_classes' => false]), true); @@ -533,29 +538,28 @@ class TypoScriptParser * @param array $setup Global setup code if $string points to a global object path. But if string is prefixed with "." then its the local setup array. * @return array An array with keys 0/1 being value/property respectively */ - public function getVal($string, $setup) + public function getVal($string, $setup): array { + $retArr = [ + 0 => '', + 1 => [], + ]; if ((string)$string === '') { - return []; + return $retArr; } [$key, $remainingKey] = $this->parseNextKeySegment($string); $subKey = $key . '.'; if ($remainingKey === '') { - $retArr = []; - if (isset($setup[$key])) { - $retArr[0] = $setup[$key]; - } - if (isset($setup[$subKey])) { - $retArr[1] = $setup[$subKey]; - } + $retArr[0] = $setup[$key] ?? $retArr[0]; + $retArr[1] = $setup[$subKey] ?? $retArr[1]; return $retArr; } if (isset($setup[$subKey])) { return $this->getVal($remainingKey, $setup[$subKey]); } - return []; + return $retArr; } /** diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index defd173d257dd5e5ae750bc33bf41f1db5f842b9..92809a9ee7c1ee40d79bf161063c6e7460c35f3b 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -725,7 +725,7 @@ class ContentObjectRenderer implements LoggerAwareInterface // $name and $conf is loaded with the referenced values. $confOverride = is_array($conf) ? $conf : []; [$name, $conf] = $cF->getVal($key, $this->getTypoScriptFrontendController()->tmpl->setup); - $conf = array_replace_recursive(is_array($conf) ? $conf : [], $confOverride); + $conf = array_replace_recursive($conf, $confOverride); // Getting the cObject $timeTracker->incStackPointer(); $content .= $this->cObjGetSingle($name, $conf, $key); @@ -5552,9 +5552,9 @@ class ContentObjectRenderer implements LoggerAwareInterface ) { $setupArray = $tsfe->tmpl->setup; } - $conf = $cF->getVal($key, $setupArray)[1] ?? []; + $conf = $cF->getVal($key, $setupArray)[1]; if (is_array($old_conf) && !empty($old_conf)) { - $conf = is_array($conf) ? array_replace_recursive($conf, $old_conf) : $old_conf; + $conf = array_replace_recursive($conf, $old_conf); } $confArr[$prop . '.'] = $conf; }