[BUGFIX] Consider routes for URLs in record lists 12/44712/2
authorMarkus Klein <markus.klein@typo3.org>
Fri, 13 Nov 2015 20:46:38 +0000 (21:46 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Fri, 13 Nov 2015 20:58:14 +0000 (21:58 +0100)
Resolves: #71302
Releases: master
Change-Id: Id5f92b032aef58e16a056b40c381d61fc0c9ad2f
Reviewed-on: https://review.typo3.org/44712
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
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;
     }
 
     /**