[BUGFIX] Consider routes for URLs in record lists
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / RecordList / AbstractDatabaseRecordList.php
index bd0d08f..97548e8 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Recordlist\RecordList;
  */
 
 use TYPO3\CMS\Backend\RecordList\AbstractRecordList;
+use TYPO3\CMS\Backend\Routing\Router;
+use TYPO3\CMS\Backend\Routing\UriBuilder;
 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
@@ -952,7 +954,17 @@ class AbstractDatabaseRecordList extends AbstractRecordList
 
         $urlParameters = array_merge_recursive($urlParameters, $this->overrideUrlParameters);
 
-        return BackendUtility::getModuleUrl(GeneralUtility::_GP('M'), $urlParameters);
+        if ($routePath = GeneralUtility::_GP('route')) {
+            $router = GeneralUtility::makeInstance(Router::class);
+            $route = $router->match($routePath);
+            $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
+            $url = (string)$uriBuilder->buildUriFromRoute($route->getOption('_identifier'), $urlParameters);
+        } elseif ($moduleName = GeneralUtility::_GP('M')) {
+            $url = BackendUtility::getModuleUrl($moduleName, $urlParameters);
+        } else {
+            $url = GeneralUtility::getIndpEnv('SCRIPT_NAME') . '?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&');
+        }
+        return $url;
     }
 
     /**