Issue Bug Under Review Quiet

#106757PageErrorHandler: Subrequest should handle redirects

Stefan Neufeind 05/23/25, 09:25 updated 10/30/26, 16:45

Description

In EXT:core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php with subrequests (experimental since TYPO3 v11, default since TYPO3 v12) there is a check for the resultcode of a subrequest:

if ($subResponse->getStatusCode() >= 300)

We have a case where a redirection-middleware (custom extension) generates redirects if needed and returns

$response = new RedirectResponse($uri, 307);

This can lead to cases where even the error-document can be a redirect. And when the subrequest returns this leads to an exception:

throw new \RuntimeException(sprintf(‘Error handler could not fetch error page “%s”, status code: %s’, $resolvedUrl, $subResponse->getStatusCode()), 1544172839);

Imho also our internal subrequests should support following redirects, maybe with a max-redirect-counter to avoid loops (like Guzzle and browsers also do). Can we maybe handle all redirects (status-codes in the 300-range) internally for subrequests and not throw an exception?

Reviews 1

History 24

  1. Stefan Neufeind commented <span data-processor="relativetime" data-value="2025-05-23T12:12:51+00:00" > 05/23/25, 12:12 </span>

    We might need to parse the “location” provided by a RedirectResponse since it can contain a URL. handlePageError() currently handles only internal requests (to a certain pid) and otherwise sends external Requests (does not use a subrequest). That’s generally okay – but if the URL can be resolved to a pid (is an internal page) it should be a candidate for a subrequest. Maybe we need RedirectResponse to be able to be an internal link (like with a t3://-url) instead of creating an uri first? Otherwise we create an uri to redirect to a certain page just to parse it again afterwards and fine which pid it linked to.