#91425404 Error page content is not being rendered since TYPO3 10.4 LTS
Description
404 Error page content is not being rendered since TYPO3 10.4 LTS, evenif it was working for intermediate TYPO3 10.3 version. When i checked the TYPO3\CMS\Core\Error\PageErrorHandler\PageContentErrorHandler found that content of error handling page is not being sent with the response
public function handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
{
try {
$resolvedUrl = $this->resolveUrl($request, $this->errorHandlerConfiguration['errorContentSource']);
$content = null;
if ($resolvedUrl !== (string)$request->getUri()) {
try {
$response = GeneralUtility::makeInstance(RequestFactory::class)->request($resolvedUrl, 'GET');
} catch (\Exception $e) {
throw new \RuntimeException('Error handler could not fetch error page "' . $resolvedUrl . '", reason: ' . $e->getMessage(), 1544172838);
}
if ($response->getStatusCode() >= 300) {
throw new \RuntimeException('Error handler could not fetch error page "' . $resolvedUrl . '", status code: ' . $response->getStatusCode(), 1544172839);
}
return $response->withStatus($this->statusCode);
}
$content = 'The error page could not be resolved, as the error page itself is not accessible';
} catch (InvalidRouteArgumentsException | SiteNotFoundException $e) {
$content = 'Invalid error handler configuration: ' . $this->errorHandlerConfiguration['errorContentSource'];
}
return new HtmlResponse($content, $this->statusCode);
}
So a workaround like following works for me :
diff -ruN a/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php b/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php
--- a/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php 2020-05-12 12:41:40.000000000 +0200
+++ b/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php 2020-05-18 09:54:04.000000000 +0200
@@ -76,12 +76,19 @@
if ($resolvedUrl !== (string)$request->getUri()) {
try {
$response = GeneralUtility::makeInstance(RequestFactory::class)->request($resolvedUrl, 'GET');
+ //patch for getting content from error handling page
+ $report = [];
+ $content = GeneralUtility::getUrl($resolvedUrl, 0, null, $report);
} catch (\Exception $e) {
throw new \RuntimeException('Error handler could not fetch error page "' . $resolvedUrl . '", reason: ' . $e->getMessage(), 1544172838);
}
if ($response->getStatusCode() >= 300) {
throw new \RuntimeException('Error handler could not fetch error page "' . $resolvedUrl . '", status code: ' . $response->getStatusCode(), 1544172839);
}
+ //patch for sending content along with status code
+ if($response->getStatusCode() == 200 && $content != null){
+ return new HtmlResponse($content, $this->statusCode);
+ }
return $response->withStatus($this->statusCode);
}
$content = 'The error page could not be resolved, as the error page itself is not accessible';Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.