From 62fea415ef23fa9ace283357dd4e23eec500ada7 Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Thu, 21 Sep 2023 19:54:51 +0200
Subject: [PATCH] [BUGFIX] Restore task group collapse state handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The scheduler module stores the information
about each tasks groups collapse state for
each user. When accessing the module, the
correct state is now resolved again.

Resolves: #101167
Releases: main, 12.4
Change-Id: I7492f90cf2c5aef634c663e5c3ef891286207007
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81162
Reviewed-by: Jochen Roth <rothjochen@gmail.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Jochen Roth <rothjochen@gmail.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
---
 .../Controller/SchedulerModuleController.php        | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
index f1c4a055d549..3a6d5e65a91b 100644
--- a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
+++ b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
@@ -566,13 +566,16 @@ final class SchedulerModuleController
         $data = $this->taskRepository->getGroupedTasks();
         $registeredClasses = $this->taskService->getAvailableTaskTypes();
 
-        foreach ($data['taskGroupsWithTasks'] as $key => $group) {
-            $group['taskGroupCollapsed'] = (bool)($moduleData->get('task-group-' . ($key ?? 0), false));
-        }
+        $groups = $data['taskGroupsWithTasks'] ?? [];
+        $groups = array_map(
+            static fn (int $key, array $group): array => array_merge($group, ['taskGroupCollapsed' => (bool)($moduleData->get('task-group-' . $key, false))]),
+            array_keys($groups),
+            $groups
+        );
 
         $view->assignMultiple([
-            'groups' => $data['taskGroupsWithTasks'],
-            'groupsWithoutTasks' => $this->getGroupsWithoutTasks($data['taskGroupsWithTasks']),
+            'groups' => $groups,
+            'groupsWithoutTasks' => $this->getGroupsWithoutTasks($groups),
             'now' => $this->context->getAspect('date')->get('timestamp'),
             'errorClasses' => $data['errorClasses'],
             'errorClassesCollapsed' => (bool)($moduleData->get('task-group-missing', false)),
-- 
GitLab