From 7851524870cf0afe88ee008179a66114df9a1a2e Mon Sep 17 00:00:00 2001
From: Torben Hansen <derhansen@gmail.com>
Date: Sun, 17 Dec 2023 19:47:08 +0100
Subject: [PATCH] [BUGFIX] Fix backend layout lookup in page info module

The page info module currently shows a valid page layout as invalid,
because the lookup of backend layouts still uses indexed array keys
instead of associative array keys which were introduced in #99739

This change fixes the problem by using associative array keys
to resolve backend layouts. Additionally, this change ensures,
that the `determinePageId` function in `BackendLayoutView`
does not try to resolve a page id, if the given array is empty.

Resolves: #102687
Related: #99739
Releases: main, 12.4
Change-Id: Iec74aec99c790c8841dbb2db537083503987f9d0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82127
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
---
 typo3/sysext/backend/Classes/View/BackendLayoutView.php       | 4 ++++
 .../info/Classes/Controller/PageInformationController.php     | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/View/BackendLayoutView.php b/typo3/sysext/backend/Classes/View/BackendLayoutView.php
index 9218ad08ffcf..c65ba163a733 100644
--- a/typo3/sysext/backend/Classes/View/BackendLayoutView.php
+++ b/typo3/sysext/backend/Classes/View/BackendLayoutView.php
@@ -109,6 +109,10 @@ class BackendLayoutView implements SingletonInterface
      */
     protected function determinePageId($tableName, array $data)
     {
+        if (empty($data)) {
+            return false;
+        }
+
         if (str_starts_with((string)$data['uid'], 'NEW')) {
             // negative uid_pid values of content elements indicate that the element
             // has been inserted after an existing element so there is no pid to get
diff --git a/typo3/sysext/info/Classes/Controller/PageInformationController.php b/typo3/sysext/info/Classes/Controller/PageInformationController.php
index e62a43725741..0b0af38a25b2 100644
--- a/typo3/sysext/info/Classes/Controller/PageInformationController.php
+++ b/typo3/sysext/info/Classes/Controller/PageInformationController.php
@@ -536,8 +536,8 @@ class PageInformationController extends InfoModuleController
         $this->backendLayoutView->addBackendLayoutItems($configuration);
         $backendLayouts = [];
         foreach ($configuration['items'] ?? [] as $backendLayout) {
-            if (($backendLayout[0] ?? false) && ($backendLayout[1] ?? false)) {
-                $backendLayouts[$backendLayout[1]] = $backendLayout[0];
+            if (($backendLayout['label'] ?? false) && ($backendLayout['value'] ?? false)) {
+                $backendLayouts[$backendLayout['value']] = $backendLayout['label'];
             }
         }
         return $backendLayouts;
-- 
GitLab