[TASK] Display exact error message of handlePageError() 26/59026/7
authorPeter Kraume <peter.kraume@gmx.de>
Tue, 4 Dec 2018 14:15:01 +0000 (15:15 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Sat, 8 Dec 2018 22:32:17 +0000 (23:32 +0100)
Show getUrl() error message when fetching content of error page.

Resolves: #87073
Releases: master
Change-Id: I9b2d548fc1d9a4bd07ea56c7d5776447c0c596d2
Reviewed-on: https://review.typo3.org/59026
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Kummer <typo3@enobe.de>
Tested-by: Joerg Kummer <typo3@enobe.de>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php

index ce44db5..01f0002 100644 (file)
@@ -63,17 +63,19 @@ class PageContentErrorHandler implements PageErrorHandlerInterface
      * @param string $message
      * @param array $reasons
      * @return ResponseInterface
+     * @throws \RuntimeException
      */
     public function handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
     {
         try {
             $resolvedUrl = $this->resolveUrl($request, $this->errorHandlerConfiguration['errorContentSource']);
             $content = null;
+            $report = [];
             if ($resolvedUrl !== (string)$request->getUri()) {
-                $content = GeneralUtility::getUrl($resolvedUrl);
-            }
-            if (!$content) {
-                $content = 'Error handler could not fetch error page: Possible recursion detected.';
+                $content = GeneralUtility::getUrl($resolvedUrl, 0, null, $report);
+                if ($content === false && ((int)$report['error'] === -1 || (int)$report['error'] > 200)) {
+                    throw new \RuntimeException('Error handler could not fetch error page "' . $resolvedUrl . '", reason: ' . $report['message'], 1544172838);
+                }
             }
         } catch (InvalidRouteArgumentsException | SiteNotFoundException $e) {
             $content = 'Invalid error handler configuration: ' . $this->errorHandlerConfiguration['errorContentSource'];