From 0a24d1e9c19bd3c8a70029bd48d20726de3afed1 Mon Sep 17 00:00:00 2001
From: Oliver Hader <oliver@typo3.org>
Date: Mon, 14 Jun 2021 18:29:55 +0200
Subject: [PATCH] [BUGFIX] Avoid crash due to endless loop in Fluid-based Page
 Module

Page Module partial `PageLayout/Record/Preview` tries to render optional
`PageLayout/Record/{item.record.CType}/Preview` and falls back to a raw
representation if that custom partial does not exist.

In case `CType` is empty, this resolves to `PageLayout/Record//Preview`
which is actually using `PageLayout/Record/Preview.html` again - that's
the partial again that initiated the process - which will after some
seconds crash due to an endless loop of that partial.

In order to make things explicit, the defaults are now located in
their dedicated namespace `RecordDefault` to avoid ambiguity.

* `PageLayout/Record/Preview` -> `PageLayout/RecordDefault/Preview`
* `PageLayout/Record/Header` -> `PageLayout/RecordDefault/Header`
* `PageLayout/Record/Footer` -> `PageLayout/RecordDefault/Footer`

Resolves: #94343
Releases: 10.4, master
Change-Id: I0c0385a9d89561de2395fc81124e471ee9fed8dd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69493
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../Resources/Private/Partials/PageLayout/Record.html       | 6 +++---
 .../PageLayout/{Record => RecordDefault}/Footer.html        | 0
 .../PageLayout/{Record => RecordDefault}/Header.html        | 0
 .../PageLayout/{Record => RecordDefault}/Preview.html       | 0
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename typo3/sysext/backend/Resources/Private/Partials/PageLayout/{Record => RecordDefault}/Footer.html (100%)
 rename typo3/sysext/backend/Resources/Private/Partials/PageLayout/{Record => RecordDefault}/Header.html (100%)
 rename typo3/sysext/backend/Resources/Private/Partials/PageLayout/{Record => RecordDefault}/Preview.html (100%)

diff --git a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record.html b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record.html
index d3c7d92713e3..a8b400bff6f0 100644
--- a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record.html
+++ b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record.html
@@ -2,16 +2,16 @@
 <div class="t3-page-ce {item.wrapperClassName} t3js-page-ce t3js-page-ce-sortable" id="element-tt_content-{item.record.uid}" data-table="tt_content" data-uid="{item.record.uid}" data-language-uid="{item.record.sys_language_uid}" style="{style}">
     <div class="t3-page-ce-dragitem" id="{item.uniqueId}">
         <f:render partial="PageLayout/Record/{item.record.CType}/Header" arguments="{_all}" optional="1">
-            <f:render partial="PageLayout/Record/Header" arguments="{_all}" />
+            <f:render partial="PageLayout/RecordDefault/Header" arguments="{_all}" />
         </f:render>
         <div class="t3-page-ce-body">
             <div class="t3-page-ce-body-inner">
                 <div class="{f:if(condition: item.versioned, then: 'ver-element')}">
-                    <f:render partial="PageLayout/Record/Preview" arguments="{_all}" />
+                    <f:render partial="PageLayout/RecordDefault/Preview" arguments="{_all}" />
                 </div>
             </div>
             <f:render partial="PageLayout/Record/{item.record.CType}/Footer" arguments="{_all}" optional="1">
-                <f:render partial="PageLayout/Record/Footer" arguments="{_all}" />
+                <f:render partial="PageLayout/RecordDefault/Footer" arguments="{_all}" />
             </f:render>
         </div>
     </div>
diff --git a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record/Footer.html b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/RecordDefault/Footer.html
similarity index 100%
rename from typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record/Footer.html
rename to typo3/sysext/backend/Resources/Private/Partials/PageLayout/RecordDefault/Footer.html
diff --git a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record/Header.html b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/RecordDefault/Header.html
similarity index 100%
rename from typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record/Header.html
rename to typo3/sysext/backend/Resources/Private/Partials/PageLayout/RecordDefault/Header.html
diff --git a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record/Preview.html b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/RecordDefault/Preview.html
similarity index 100%
rename from typo3/sysext/backend/Resources/Private/Partials/PageLayout/Record/Preview.html
rename to typo3/sysext/backend/Resources/Private/Partials/PageLayout/RecordDefault/Preview.html
-- 
GitLab