From 9e9970afa1aadc51d82e7892cf46e9d8b719ae1e Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Wed, 16 Feb 2022 16:34:15 +0100
Subject: [PATCH] [BUGFIX] Properly resolve field values in content preview

The StandardContentPreviewRenderer runs
through a list of fields, whose value should
be processed and displayed in the footer.

Some of those field values might be a reference
to a foreign table, e.g. in the "fe_group" field.
Due to changes in getProcessedValue(), it's
necessary to provide the records' uid, to be
able to resolve values of fields with a
"foreign_table" configuration.

Resolves: #96920
Releases: main, 11.5
Change-Id: I0d8739710e478a7cb264be1d5b90b70af31de964
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73563
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 .../Classes/Preview/StandardContentPreviewRenderer.php        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php b/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php
index 17e50fb27fbc..264907de81f0 100644
--- a/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php
+++ b/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php
@@ -293,8 +293,8 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
         $fieldArr = explode(',', $fieldList);
         foreach ($fieldArr as $field) {
             if ($record[$field]) {
-                $info[] = '<strong>' . htmlspecialchars((string)($itemLabels[$field] ?? '')) . '</strong> '
-                    . htmlspecialchars(BackendUtility::getProcessedValue('tt_content', $field, $record[$field]) ?? '');
+                $fieldValue = BackendUtility::getProcessedValue('tt_content', $field, $record[$field], 0, false, false, $record['uid'] ?? 0) ?? '';
+                $info[] = '<strong>' . htmlspecialchars((string)($itemLabels[$field] ?? '')) . '</strong> ' . htmlspecialchars($fieldValue);
             }
         }
     }
-- 
GitLab