Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Fix array key access in ext_getSetup (Backport 11.5) #3361

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Classes/FrontendEnvironment/TypoScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,23 @@ protected function buildConfigurationArray(int $pageId, string $path, int $langu
}

/**
* Adapted from TYPO3 core
* @see sysext:core/Classes/TypoScript/ExtendedTemplateService until TYPO3 v11
* @param array $theSetup
* @param string $theKey
* @return array
*/
public function ext_getSetup(array $theSetup, string $theKey): array
{
// 'a.b.c' --> ['a', 'b.c']
$parts = explode('.', $theKey, 2);
if ((string)$parts[0] !== '' && is_array($theSetup[$parts[0] . '.'])) {
if (trim($parts[1] ?? '') !== '') {
// Current path segment is a sub array, check it recursively by applying the rest of the key
return $this->ext_getSetup($theSetup[$parts[0] . '.'], trim($parts[1] ?? ''));
}
return [$theSetup[$parts[0] . '.'], $theSetup[$parts[0]]];
// No further path to evaluate, return current setup and the value for the current path segment - if any
return [$theSetup[$parts[0] . '.'], $theSetup[$parts[0]] ?? ''];
}
if (trim($theKey) !== '') {
return [[], $theSetup[$theKey]];
Expand Down