From b61dfba9dff5a47747bf04eb1c6ca409a0b3cb3f Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Wed, 20 Dec 2023 14:45:15 +0100
Subject: [PATCH] [BUGFIX] Omit calling `getRecordWSOL` in
 `BU::getProcessedValue()`

Since #102616, itemsProcFunc config is resolved in
`BU::getLabelFromItemlist()`. This method therefore
was adjusted to take the record in question as argument,
passing it to the underlying `ItemProcessingService`,
which actually just requires the uid and pid.

Since the database row is not passed to
BU::getProcessedValue()`, the record was
fetched for each item manually via
`getRecordWSOL()`. This is not sufficient
and has a serious performance impact.

The functionality of resolving itemsProcFunc is
now still in place but `BU::getProcessedValue()`
does no longer fetch and pass the record, but
only the uid and pid. This will therefore still
enable most use cases, but does no longer slow
down the backend.

Resolves: #102698
Related: #102616
Related: #100855
Releases: main, 12.4
Change-Id: Ic52564fada13b47f5364df642acbf683538b0c21
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82248
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/Utility/BackendUtility.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
index 04a7a257317a..2412ff8f9456 100644
--- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php
+++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
@@ -1623,7 +1623,7 @@ class BackendUtility
         $lang = static::getLanguageService();
         switch ((string)($theColConf['type'] ?? '')) {
             case 'radio':
-                $l = $lang->sL(self::getLabelFromItemlist($table, $col, $value, static::getRecordWSOL($table, (int)$uid) ?? []));
+                $l = $lang->sL(self::getLabelFromItemlist($table, $col, $value, ['uid' => (int)$uid, 'pid' => (int)$pid]));
                 if ($l === '' && !empty($value)) {
                     // Use plain database value when label is empty
                     $l = $value;
@@ -1655,7 +1655,7 @@ class BackendUtility
                             $columnTsConfig = $pageTsConfig['TCEFORM.'][$table . '.'][$col . '.'];
                         }
                     }
-                    $l = self::getLabelsFromItemsList($table, $col, (string)$value, $columnTsConfig, static::getRecordWSOL($table, (int)$uid) ?? []);
+                    $l = self::getLabelsFromItemsList($table, $col, (string)$value, $columnTsConfig, ['uid' => (int)$uid, 'pid' => (int)$pid]);
                     if (!empty($theColConf['foreign_table']) && !$l && !empty($GLOBALS['TCA'][$theColConf['foreign_table']])) {
                         if ($noRecordLookup) {
                             $l = $value;
-- 
GitLab