Skip to content

Commit

Permalink
[BUGFIX] Do not remove page cache for redirects issued by plugins
Browse files Browse the repository at this point in the history
This reverts commit 3139b56.
"[BUGFIX] Do not cache content with different status code than 200"

At the same time we convert a plugin action to uncached,
in case a redirect is issued.

Resolves: #88178
Releases: 8.7, 9.5, master
Change-Id: Icaa8038d1fa4bf1c74dfb505c2b8fc97963ca4be
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60687
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
helhum authored and bmack committed May 7, 2019
1 parent 1f5ce46 commit e855f9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Expand Up @@ -353,6 +353,14 @@ protected function redirectToUri($uri, $delay = 0, $statusCode = 303)
$this->response->setStatus($statusCode);
$this->response->setHeader('Location', (string)$uri);
}
// Avoid caching the plugin when we issue a redirect response
// This means that even when an action is configured as cachable
// we avoid the plugin to be cached, but keep the page cache untouched
$contentObject = $this->configurationManager->getContentObject();
if ($contentObject->getUserObjectType() === \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::OBJECTTYPE_USER) {
$contentObject->convertToUserIntObject();
}

throw new StopActionException('redirectToUri', 1476045828);
}

Expand Down
6 changes: 1 addition & 5 deletions typo3/sysext/frontend/Classes/Http/RequestHandler.php
Expand Up @@ -285,11 +285,7 @@ public function handleRequest(\Psr\Http\Message\ServerRequestInterface $request)
$GLOBALS['error']->debugOutput();
}
GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, ['_FLUSH' => true]);
// if any code set a response code that is not 200 clear the cache's content
// if we fail to do so we would deliver cache content with a wrong header, which causes big mess.
if (http_response_code() !== 200) {
$this->controller->clearPageCacheContent();
}

return $response;
}

Expand Down

0 comments on commit e855f9c

Please sign in to comment.