Commit 04e55537 authored by Nikita Hovratov's avatar Nikita Hovratov Committed by Christian Kuhn
Browse files

[BUGFIX] Fix warning in TypoScriptParser

The method getVal now always returns an array with
a string at index 0 and an array at index 1.

Resolves: #96001
Releases: master, 11.5
Change-Id: Ia1b321694767fa01b1de9176b87470522511d150
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72195

Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 3a6c6ee3
......@@ -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;
}
/**
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment