From c563623bb39790d586a4aef1ef76cc61625bb699 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Thu, 11 Apr 2024 10:40:24 +0200
Subject: [PATCH] [BUGFIX] Avoid deleted workspace relations in RootlineUtility

RootlineUtility uses RelationHandler to resolve relations
attached to pages. The tests from #103598 show that relations
which are set to deleted ("delete placeholder", t3ver_state=2)
are not considered and still part of the result set. The
patch adds a missing call to prevent these.

Resolves: #103599
Related: #103598
Releases: main, 12.4
Change-Id: Ie580e4d9b64c477d8c9d6d4092114c18f43a2a70
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83739
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
---
 typo3/sysext/core/Classes/Utility/RootlineUtility.php         | 1 +
 .../core/Tests/Functional/Utility/RootlineUtilityTest.php     | 4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/core/Classes/Utility/RootlineUtility.php b/typo3/sysext/core/Classes/Utility/RootlineUtility.php
index 656b183671a7..6a0cbae8dfa2 100644
--- a/typo3/sysext/core/Classes/Utility/RootlineUtility.php
+++ b/typo3/sysext/core/Classes/Utility/RootlineUtility.php
@@ -255,6 +255,7 @@ class RootlineUtility
                         'pages',
                         $fieldConfig
                     );
+                    $relationHandler->processDeletePlaceholder();
                     $relatedUids = $relationHandler->getValueArray();
                 }
                 $pageRecord[$column] = implode(',', $relatedUids);
diff --git a/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php b/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php
index c10c4bf98011..3c67a7cce3f5 100644
--- a/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php
+++ b/typo3/sysext/core/Tests/Functional/Utility/RootlineUtilityTest.php
@@ -659,9 +659,7 @@ final class RootlineUtilityTest extends FunctionalTestCase
                 2 => [
                     'uid' => 1051,
                     'title' => 'EN WS2-changed Parent 5 Sub 1 with media deleted',
-                    // @todo: bug. 1201 is included, but should not, since it has a delete placeholder.
-                    //        this is because $relationHandler->processDeletePlaceholder() is not called.
-                    'media' => '1201,1200',
+                    'media' => '1200',
                 ],
                 1 => [
                     'uid' => 1050,
-- 
GitLab