From 69849b3f1a8f1635b445ca4012d6c36d731d5439 Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Tue, 11 Jul 2023 09:20:56 +0200
Subject: [PATCH] [BUGFIX] Keep link handler settings in filelist url
 generation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Since a filelist instance is used in the
link browser for the file and folder types,
the link generation of the filelist need
to keep corresponding parameters.

Resolves: #101306
Releases: main, 12.4
Change-Id: I012a1c0cf22d1e97c0b82a59c189823314ccf912
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79958
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan B�rk <stefan@buerk.tech>
Tested-by: Stefan B�rk <stefan@buerk.tech>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 typo3/sysext/filelist/Classes/FileList.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php
index 8722c1af17ea..a09fe7ad2bbb 100644
--- a/typo3/sysext/filelist/Classes/FileList.php
+++ b/typo3/sysext/filelist/Classes/FileList.php
@@ -1457,13 +1457,21 @@ class FileList
             $baseParams['bparams'] = $bparams;
         }
 
+        // Keep LinkHandler Settings
+        if ($act = ($parsedBody['act'] ?? $queryParams['act'] ?? null)) {
+            $baseParams['act'] = $act;
+        }
+        if ($linkHandlerParams = ($parsedBody['P'] ?? $queryParams['P'] ?? null)) {
+            $baseParams['P'] = $linkHandlerParams;
+        }
+
         $params = array_replace_recursive($baseParams, $params);
 
         // Expanded folder is used in the element browser.
         // We always map it to the id here.
         $params['expandFolder'] = $params['id'];
         $params = array_filter($params, static function ($value) {
-            return $value !== null && trim($value) !== '';
+            return (is_string($value) && trim($value) !== '') || (is_array($value) && $value !== []);
         });
 
         return (string)$this->uriBuilder->buildUriFromRoute($route->getOption('_identifier'), $params);
-- 
GitLab