[TASK] Optimizing ElementHistoryController 27/43327/2
authorMichael Oehlhof <typo3@oehlhof.de>
Tue, 15 Sep 2015 12:23:01 +0000 (14:23 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 15 Sep 2015 17:09:28 +0000 (19:09 +0200)
The function getButtons() has instantiated the class RecordHistory only
for getting the returnUrl parameter.
This is replaced by GeneralUtility::_GP() and
GeneralUtility::sanitizeLocalUrl()

Resolves: #69823
Releases: master
Change-Id: I43668728c8cbb46cac7e0d2f4ebf7892af17ef3f
Reviewed-on: http://review.typo3.org/43327
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php

index 711cb61..d58b3ad 100644 (file)
@@ -130,11 +130,11 @@ class ElementHistoryController implements \TYPO3\CMS\Core\Http\ControllerInterfa
                );
                // CSH
                $buttons['csh'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'history_log');
-               // Start history object
-               $historyObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\History\RecordHistory::class);
-               if ($historyObj->returnUrl) {
+               // Get returnUrl parameter
+               $returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
+               if ($returnUrl) {
                        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
-                       $buttons['back'] = '<a href="' . htmlspecialchars($historyObj->returnUrl) . '" class="typo3-goBack">' . $iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL) . '</a>';
+                       $buttons['back'] = '<a href="' . htmlspecialchars($returnUrl) . '" class="typo3-goBack">' . $iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL) . '</a>';
                }
                return $buttons;
        }