Project

General

Profile

Actions

Bug #91425

closed

404 Error page content is not being rendered since TYPO3 10.4 LTS

Added by Ricky Mathew Kuruvilla almost 4 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
Start date:
2020-05-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
errorhandling
Complexity:
easy
Is Regression:
Sprint Focus:

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';
Actions #1

Updated by Oliver Bartsch over 2 years ago

  • Status changed from New to Needs Feedback

Hi, I just checked this in the latest v10. I'm not able to reproduce this anymore.

I configured an error handler like this:

errorHandling:
  -
    errorCode: 404
    errorHandler: Page
    errorContentSource: 't3://page?uid=37'

On accessing a non existing site, the content of page 37 is rendered.

Could you please check if the issue still exists for you?

Actions #2

Updated by Christian Kuhn about 2 years ago

  • Status changed from Needs Feedback to Closed

hey. i hope it's ok to close here for now: the issue has likely been resolved meanwhile. please ping us to re-open, or create a fresh issue in case the problem persists.

Actions

Also available in: Atom PDF