Project

General

Profile

Actions

Feature #64566

closed

AbstractController::redirect should have a noCacheHash parameter

Added by Tizian Schmidlin over 9 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2015-01-28
Due date:
% Done:

90%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Hello there,

I recently experienced the need to deactivate all cHash parameters and was lastly stuck at my redirect that would not redirect without a cHash.

I figured out, that there is no way to deactivate it, opposed to the f:link.action or f:link.page from fluid.

So I built this (basically added the functionality to the method):

    /**
     * Redirects the request to another action and / or controller.
     *
     * Redirect will be sent to the client which then performs another request to the new URI.
     *
     * NOTE: This method only supports web requests and will thrown an exception
     * if used with other request types.
     *
     * @param string $actionName Name of the action to forward to
     * @param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used.
     * @param string $extensionName Name of the extension containing the controller to forward to. If not specified, the current extension is assumed.
     * @param array $arguments Arguments to pass to the target action
     * @param integer $pageUid Target page uid. If NULL, the current page uid is used
     * @param integer $delay (optional) The delay in seconds. Default is no delay.
     * @param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other
     * @param boolean $noCacheHash (optional) Choose to not append a cHash to the generated url.
     * @return void
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException If the request is not a web request
     * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
     * @see forward()
     * @api
     */
    protected function redirect($actionName, $controllerName = NULL, $extensionName = NULL, array $arguments = NULL, $pageUid = NULL, $delay = 0, $statusCode = 303, $noCacheHash = false) {
        if (!$this->request instanceof \TYPO3\CMS\Extbase\Mvc\Web\Request) {
            throw new \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException('redirect() only supports web requests.', 1220539734);
        }
        if ($controllerName === NULL) {
            $controllerName = $this->request->getControllerName();
        }
        $this->uriBuilder->reset()->setTargetPageUid($pageUid)->setCreateAbsoluteUri(TRUE)->setUseCacheHash(!$noCacheHash);
        if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
            $this->uriBuilder->setAbsoluteUriScheme('https');
        }
        $uri = $this->uriBuilder->uriFor($actionName, $arguments, $controllerName, $extensionName);
        $this->redirectToUri($uri, $delay, $statusCode);
    }

Best regards
Tizian

Actions #1

Updated by Mathias Schreiber over 9 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Mathias Schreiber

Hi Tizian,

if you push this change to our Review Server, we can get this thing cooking.

If you need a walkthrough, contact me on Slack.

cheers
Mathias

Actions #2

Updated by Gerrit Code Review almost 9 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39449

Actions #3

Updated by Mathias Brodala almost 9 years ago

Can you avoid this issue with redirecting from an uncached action to an uncached action? There was a change recently which automatically disables the cache hash in this case.

Actions #4

Updated by Helmut Hummel almost 9 years ago

  • Status changed from Under Review to Needs Feedback

Tizian Schmidlin wrote:

I recently experienced the need to deactivate all cHash parameters and was lastly stuck at my redirect that would not redirect without a cHash.

Can you explain, why you needed to do so? It is not apparent to me why doing so could be required.

Actions #5

Updated by Alexander Opitz over 8 years ago

  • Status changed from Needs Feedback to Closed
  • Assignee deleted (Mathias Schreiber)

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions #6

Updated by Gerrit Code Review over 8 years ago

  • Status changed from Closed to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39449

Actions #7

Updated by Helmut Hummel over 8 years ago

  • Status changed from Under Review to Closed

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions #8

Updated by Markus Timtner over 6 years ago

  • Status changed from Closed to New
  • % Done changed from 0 to 90

Im proposing to open this issue again, bvecause the fix provided works.
Although it seems to be a very rare feature used, it still is necessary sometimes.

I have tested and verified the fix provided,
it could be merged to master now.

Actions #9

Updated by Riccardo De Contardi over 5 years ago

  • Category set to Extbase
Actions #10

Updated by Benni Mack over 4 years ago

  • Status changed from New to Closed

With TYPO3 v9 and site handling, the option to disable cHash generation is not available anymore, as TYPO3 takes care of that automatically. If you do want to exclude cHash generation for your redirect, I'd recommend to use proper RouteEnhancers or exclude the added parameters from your LocalConfiguration.php.

As we're moving away from having developers and integrators worry about when to add or remove a cHash, we won't add this feature request in that way - more specifically because I still do not see a use case for that that could not be handled in other places (typolink and PageRouter is the place to do this kind of thing).

Actions

Also available in: Atom PDF