From 8c393e644bac837d7bf9594ef2f6a5b82b87d6cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chris=20M=C3=BCller?= <typo3@krue.ml>
Date: Tue, 21 Dec 2021 16:40:45 +0100
Subject: [PATCH] [BUGFIX] Avoid PHP8 warning for "Insert records" with hidden
 records

When one or more hidden records are referenced in an "Insert records"
content element, an "undefined array key" warning was thrown.

Resolves: #96419
Releases: main, 11.5
Change-Id: I4f90dc78540bf8c56163cfb8247a13c86869fbe1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72762
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../frontend/Classes/ContentObject/RecordsContentObject.php  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
index ec8c984e2a90..08faacd9de42 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/RecordsContentObject.php
@@ -94,7 +94,10 @@ class RecordsContentObject extends AbstractContentObject
                 $cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
                 $this->cObj->currentRecordNumber = 0;
                 foreach ($this->itemArray as $val) {
-                    $row = $this->data[$val['table']][$val['id']];
+                    $row = $this->data[$val['table']][$val['id']] ?? null;
+                    if ($row === null) {
+                        continue;
+                    }
                     // Perform overlays if necessary (records coming from category collections are already overlaid)
                     if ($source) {
                         // Versioning preview
-- 
GitLab