From 13d6480541779544b40b02b8952f04c5c21e59e9 Mon Sep 17 00:00:00 2001
From: Daniel Windloff <daniel.jc.windloff@googlemail.com>
Date: Fri, 25 Sep 2020 11:37:42 +0200
Subject: [PATCH] [TASK] Recordlist: Replace
 BackendUtility::getLinkToDataHandlerAction

Replace BackendUtility::getLinkToDataHandlerAction and use the
uriBuilder instead.

Releases: master
Resolves: #92407
Change-Id: I96b2f1698aa5dcf056fa24fd548c01cc3fb4ce6f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65873
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Controller/RecordListController.php       |  9 +++---
 .../Classes/RecordList/DatabaseRecordList.php | 32 ++++++++++++-------
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php
index 2f58f2943381..9086f21907cf 100644
--- a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php
+++ b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php
@@ -450,11 +450,10 @@ class RecordListController
                     'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
                 ];
                 $redirectUrl = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $parameters);
-                $targetUrl = BackendUtility::getLinkToDataHandlerAction(
-                    '&cmd[pages][' . $id . '][localize]=' . $languageUid,
-                    $redirectUrl
-                );
-
+                $params = [];
+                $params['redirect'] = $redirectUrl;
+                $params['cmd']['pages'][$id]['localize'] = $languageUid;
+                $targetUrl = (string)$this->uriBuilder->buildUriFromRoute('tce_db', $params);
                 $output .= '<option value="' . htmlspecialchars($targetUrl) . '">' . htmlspecialchars($languageTitle) . '</option>';
             }
 
diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
index c81329d36cf5..08067dec28a1 100644
--- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
+++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
@@ -1846,8 +1846,10 @@ class DatabaseRecordList
             if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
                 if (!$isL10nOverlay && !$isDeletePlaceHolder && isset($this->currentTable['prev'][$row['uid']])) {
                     // Up
-                    $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
-                    $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
+                    $params = [];
+                    $params['redirect'] = $this->listURL();
+                    $params['cmd'][$table][$row['uid']]['move'] = $this->currentTable['prev'][$row['uid']];
+                    $url = (string)$this->uriBuilder->buildUriFromRoute('tce_db', $params);
                     $moveUpAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
                         . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
                 } else {
@@ -1857,8 +1859,10 @@ class DatabaseRecordList
 
                 if (!$isL10nOverlay && !$isDeletePlaceHolder && $this->currentTable['next'][$row['uid']]) {
                     // Down
-                    $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
-                    $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
+                    $params = [];
+                    $params['redirect'] = $this->listURL();
+                    $params['cmd'][$table][$row['uid']]['move'] = $this->currentTable['next'][$row['uid']];
+                    $url = (string)$this->uriBuilder->buildUriFromRoute('tce_db', $params);
                     $moveDownAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
                         . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
                 } else {
@@ -1937,8 +1941,10 @@ class DatabaseRecordList
                 // Up (Paste as the page right after the current parent page)
                 if ($this->calcPerms->createPagePermissionIsGranted()) {
                     if (!$isDeletePlaceHolder && !$isL10nOverlay) {
-                        $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
-                        $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
+                        $params = [];
+                        $params['redirect'] = $this->listURL();
+                        $params['cmd'][$table][$row['uid']]['move'] = -$this->id;
+                        $url = (string)$this->uriBuilder->buildUriFromRoute('tce_db', $params);
                         $moveLeftAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
                             . $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
                         $this->addActionToCellGroup($cells, $moveLeftAction, 'moveLeft');
@@ -1950,8 +1956,10 @@ class DatabaseRecordList
                 if (!$isL10nOverlay && !$isDeletePlaceHolder && $this->currentTable['prevUid'][$row['uid']]) {
                     $localCalcPerms = new Permission($backendUser->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']])));
                     if ($localCalcPerms->createPagePermissionIsGranted()) {
-                        $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
-                        $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
+                        $params = [];
+                        $params['redirect'] = $this->listURL();
+                        $params['cmd'][$table][$row['uid']]['move'] = $this->currentTable['prevUid'][$row['uid']];
+                        $url = (string)$this->uriBuilder->buildUriFromRoute('tce_db', $params);
                         $moveRightAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
                             . $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
                     } else {
@@ -2201,10 +2209,10 @@ class DatabaseRecordList
                             'returnUrl' => $this->listURL()
                         ]
                 );
-                $href = BackendUtility::getLinkToDataHandlerAction(
-                    '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
-                    $redirectUrl
-                );
+                $params = [];
+                $params['redirect'] = $redirectUrl;
+                $params['cmd'][$table][$row['uid']]['localize'] = $lUid_OnPage;
+                $href = (string)$this->uriBuilder->buildUriFromRoute('tce_db', $params);
                 $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title');
                 if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
                     $lC = $this->iconFactory->getIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL)->render();
-- 
GitLab