From a6f21085cb2ec38348e5d372218d956f566d92fd Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Thu, 25 Nov 2021 12:29:25 +0100
Subject: [PATCH] [BUGFIX] Prevent PHP warning in OpendocsToolbarItem
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In case a record from a no longer existing
table is stored as recently opened in the
user session, a PHP warning is triggered
whenever the toolbar items are updated
(e.g. because user opens another record).

This is fixed by adding corresponding fallbacks.

Resolves: #96075
Releases: master, 11.5
Change-Id: Ia99371711f2a8ef9fa6a96844476148674b5b843
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72285
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 .../Classes/Backend/ToolbarItems/OpendocsToolbarItem.php      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php
index c0cd8e06c61e..40ae5768988a 100644
--- a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php
+++ b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php
@@ -161,8 +161,8 @@ class OpendocsToolbarItem implements ToolbarItemInterface
      */
     protected function getMenuEntry(array $document, string $identifier): array
     {
-        $table = $document[3]['table'];
-        $uid = $document[3]['uid'];
+        $table = $document[3]['table'] ?? '';
+        $uid = $document[3]['uid'] ?? 0;
         $record = BackendUtility::getRecordWSOL($table, $uid);
 
         if (!is_array($record)) {
-- 
GitLab