Project

General

Profile

Actions

Bug #106757

open

PageErrorHandler: Subrequest should handle redirects

Added by Stefan Neufeind 27 days ago. Updated 27 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2025-05-23
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
14
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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?

Actions #1

Updated by Stefan Neufeind 27 days ago

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.

Actions

Also available in: Atom PDF