Commit adb73680 authored by Wolfgang Klinger's avatar Wolfgang Klinger Committed by Christian Kuhn
Browse files

[BUGFIX] Make sure that foreach loops are applied to arrays only

Fix some foreach loops so as not to run into potentially empty elements.
Use the ?? operator to accomplish that.

Change-Id: Id6306cea0546dfd4a20ba98c170335966cc2ae40
Resolves: #83322
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/55066


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent d9f4eb0f
......@@ -108,7 +108,9 @@ abstract class AbstractNode implements NodeInterface, LoggerAwareInterface
}
/**
* Merge existing data with a child return array
* Merge existing data with a child return array.
* The incoming $childReturn array should be initialized
* using initializeResultArray() beforehand.
*
* @param array $existing Currently merged array
* @param array $childReturn Array returned by child
......@@ -120,27 +122,23 @@ abstract class AbstractNode implements NodeInterface, LoggerAwareInterface
if ($mergeHtml && !empty($childReturn['html'])) {
$existing['html'] .= LF . $childReturn['html'];
}
foreach ($childReturn['additionalJavaScriptPost'] as $value) {
foreach ($childReturn['additionalJavaScriptPost'] ?? [] as $value) {
$existing['additionalJavaScriptPost'][] = $value;
}
foreach ($childReturn['additionalJavaScriptSubmit'] as $value) {
foreach ($childReturn['additionalJavaScriptSubmit'] ?? [] as $value) {
$existing['additionalJavaScriptSubmit'][] = $value;
}
foreach ($childReturn['additionalHiddenFields'] as $value) {
foreach ($childReturn['additionalHiddenFields'] ?? [] as $value) {
$existing['additionalHiddenFields'][] = $value;
}
foreach ($childReturn['stylesheetFiles'] as $value) {
foreach ($childReturn['stylesheetFiles'] ?? [] as $value) {
$existing['stylesheetFiles'][] = $value;
}
if (!empty($childReturn['requireJsModules'])) {
foreach ($childReturn['requireJsModules'] as $module) {
$existing['requireJsModules'][] = $module;
}
foreach ($childReturn['requireJsModules'] ?? [] as $module) {
$existing['requireJsModules'][] = $module;
}
if (!empty($childReturn['additionalInlineLanguageLabelFiles'])) {
foreach ($childReturn['additionalInlineLanguageLabelFiles'] as $inlineLanguageLabelFile) {
$existing['additionalInlineLanguageLabelFiles'][] = $inlineLanguageLabelFile;
}
foreach ($childReturn['additionalInlineLanguageLabelFiles'] ?? [] as $inlineLanguageLabelFile) {
$existing['additionalInlineLanguageLabelFiles'][] = $inlineLanguageLabelFile;
}
if (!empty($childReturn['inlineData'])) {
$existingInlineData = $existing['inlineData'];
......
Supports Markdown
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