Skip to content

Commit

Permalink
[BUGFIX] Do not overwrite status code of received response
Browse files Browse the repository at this point in the history
The ErrorController must not modify the received response
from the configured handler, to allow the handler to
change it to a suitable value.

Resolves: #87846
Releases: master, 9.5
Change-Id: I91d3ab0a78d383e5a0c9ee47ea21dc8634ddd3c9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60318
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 Mar 23, 2019
1 parent 76ea9cc commit 2f612f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public function handlePageError(ServerRequestInterface $request, string $message
'message' => $message,
'reasons' => $reasons
]);
return new HtmlResponse($this->view->render());
return new HtmlResponse($this->view->render(), $this->statusCode);
}
}
9 changes: 3 additions & 6 deletions typo3/sysext/frontend/Classes/Controller/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public function unavailableAction(ServerRequestInterface $request, string $messa
}
$errorHandler = $this->getErrorHandlerFromSite($request, 500);
if ($errorHandler instanceof PageErrorHandlerInterface) {
$response = $errorHandler->handlePageError($request, $message, $reasons);
return $response->withStatus(500, $message);
return $errorHandler->handlePageError($request, $message, $reasons);
}
return $this->handlePageError(
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling'],
Expand All @@ -75,8 +74,7 @@ public function pageNotFoundAction(ServerRequestInterface $request, string $mess
{
$errorHandler = $this->getErrorHandlerFromSite($request, 404);
if ($errorHandler instanceof PageErrorHandlerInterface) {
$response = $errorHandler->handlePageError($request, $message, $reasons);
return $response->withStatus(404, $message);
return $errorHandler->handlePageError($request, $message, $reasons);
}
if (!$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
throw new PageNotFoundException($message, 1518472189);
Expand All @@ -102,8 +100,7 @@ public function accessDeniedAction(ServerRequestInterface $request, string $mess
{
$errorHandler = $this->getErrorHandlerFromSite($request, 403);
if ($errorHandler instanceof PageErrorHandlerInterface) {
$response = $errorHandler->handlePageError($request, $message, $reasons);
return $response->withStatus(403, $message);
return $errorHandler->handlePageError($request, $message, $reasons);
}
return $this->handlePageError(
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'],
Expand Down

0 comments on commit 2f612f4

Please sign in to comment.