From ea6e19a5b301e0ee0455ad1ac71221108250c9e4 Mon Sep 17 00:00:00 2001
From: Thomas Hohn <tho@gyldendal.dk>
Date: Mon, 14 Aug 2023 13:51:55 +0200
Subject: [PATCH] [BUGFIX] Fix Undefined array key warning in
 InlineRecordContainer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix undefined array key 0 in `InlineRecordContainer` by adding
a null coalescing operator and handling `$uid` properly.

Resolves: #101682
Releases: 11.5
Change-Id: I510c4af4dacfd9b1fb8110bf43b192c87918450f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80548
Reviewed-by: J�rg B�sche <typo3@joergboesche.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
---
 .../backend/Classes/Form/Container/InlineRecordContainer.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
index b012197a5566..923d2fb6f578 100644
--- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
@@ -486,7 +486,7 @@ class InlineRecordContainer extends AbstractContainer
         // "Info": (All records)
         // @todo: hardcoded sys_file!
         if ($rec['table_local'] === 'sys_file') {
-            $uid = $rec['uid_local'][0]['uid'];
+            $uid = $rec['uid_local'][0]['uid'] ?? 0;
             $table = '_FILE';
         } else {
             $uid = $rec['uid'];
@@ -495,7 +495,7 @@ class InlineRecordContainer extends AbstractContainer
         if ($enabledControls['info']) {
             if ($isNewItem) {
                 $cells['info'] = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
-            } else {
+            } elseif ($uid > 0) {
                 $cells['info'] = '
 				<button type="button" class="btn btn-default" data-action="infowindow" data-info-table="' . htmlspecialchars($table) . '" data-info-uid="' . htmlspecialchars($uid) . '" title="' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:showInfo')) . '">
 					' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '
@@ -545,6 +545,7 @@ class InlineRecordContainer extends AbstractContainer
             }
             // "Edit" link:
             if (($rec['table_local'] === 'sys_file')
+                && ($uid > 0)
                 && !$isNewItem
                 && ($languageField = ($GLOBALS['TCA']['sys_file_metadata']['ctrl']['languageField'] ?? false))
                 && $backendUser->check('tables_modify', 'sys_file_metadata')
-- 
GitLab