From e7a907ec1b3043a592388fc99e37ac97259d43bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20E=C3=9Fl?= <indy.essl@gmail.com>
Date: Sat, 22 Feb 2020 14:09:45 +0100
Subject: [PATCH] [BUGFIX] Fallback to default, if BackendLayout can no longer
 be resolved

In the new fluidbased page module view, if a previously configured
BackendLayout has been removed. (For instance, the extension providing
it has been removed), the module would throw an uncaught error, because
the script would try to call a method on a non-existing BackendLayout.

This patch fixes this problem by automatically falling back to the
"default" BackendLayout, if the requested one couldn't be provided.
This is the same way as the old PageLayoutView would have reacted to
this problem.

Resolves: #90479
Releases: master
Change-Id: I76127e9b53bcb0ac55875857ca11262a323c6013
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63370
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Claus Due <claus@phpmind.net>
Tested-by: Kevin Appelt <kevin.appelt@icloud.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Claus Due <claus@phpmind.net>
Reviewed-by: Kevin Appelt <kevin.appelt@icloud.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
---
 .../backend/Classes/Controller/PageLayoutController.php   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
index c4485d0dc1e0..60b3f7c3ead0 100644
--- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
+++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
@@ -623,6 +623,14 @@ class PageLayoutController
                 $this->id
             );
 
+            // If backend layout is not found available anymore, use default
+            if ($backendLayout === null) {
+                $backendLayout = $this->backendLayouts->getDataProviderCollection()->getBackendLayout(
+                    'default',
+                    $this->id
+                );
+            }
+
             $configuration = $backendLayout->getDrawingConfiguration();
             $configuration->setPageId($this->id);
             $configuration->setDefaultLanguageBinding(!empty($this->modTSconfig['properties']['defLangBinding']));
-- 
GitLab