From 2642faefafd3799e0d911ecf3a5b82320035deec Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Mon, 23 Oct 2023 14:47:23 +0200
Subject: [PATCH] [BUGFIX] Avoid PHP array access error in workspaces

When a page with a content element that has images
assigned is copied in workspaces, a PHP array access
error is raised since sys_file_reference TCA has
no sortby ctrl.

Add an appropriate null fallback.

Resolves: #102231
Releases: main, 12.4, 11.5
Change-Id: I453a612a62a359156c8be2e087d1d121f1b9c3ea
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81467
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
---
 typo3/sysext/core/Classes/DataHandling/DataHandler.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
index 7fa5478c738d..5d7922f6253e 100644
--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -3531,7 +3531,7 @@ class DataHandler implements LoggerAwareInterface
                                 $this->resolveVersionedRecords(
                                     $table,
                                     implode(',', $fields),
-                                    $GLOBALS['TCA'][$table]['ctrl']['sortby'],
+                                    $GLOBALS['TCA'][$table]['ctrl']['sortby'] ?? '',
                                     array_keys($rows)
                                 ),
                                 true
-- 
GitLab