Review main Merged

98009[BUGFIX] Improve handling of error pages that are not available

Matthias Vogel CR +2 V +2 Hard +336 −25 updated 11/28/26, 10:49

Commit message

PageContentErrorHandler shows the configured error page of a site.
This change improves what the handler does when it cannot show the
error page.

Before this change, the handler showed the root page when the error
page was hidden or outside its start and end time. When the
sub-request could not get the error page, the visitor got the status
code 500. This occurred, for example, when only a frontend user group
had access to the error page.

Now the handler builds the URI of the error page also when the error
page is hidden or outside its start and end time. When the handler
cannot get the error page, it sends the TYPO3 error page with the
original status code. The handler also logs a warning with the URI of
the error page. The warning also gives the status code of the
sub-request or of the external request, or the error message of the
external request. A backend user who can see hidden pages gets the
hidden error page.

As ErrorController does, the handler adds the Content-Security-Policy
headers of the site to the TYPO3 error page.
Show more Show less

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 3

Files 4

Review log 818

  1. Matthias Vogel uploaded patch set 1 11/25/26, 11:15

  2. core-ci voted on patch set 1 V -1 11/25/26, 11:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115415

  3. core-ci commented on patch set 1 11/25/26, 12:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115415

  4. Matthias Vogel rebased onto patch set 2 V -1 11/25/26, 13:10

  5. core-ci voted on patch set 2 V -1 11/25/26, 13:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115442

  6. core-ci commented on patch set 2 11/25/26, 13:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115442

  7. core-ci commented on patch set 2 11/25/26, 13:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115442

  8. core-ci commented on patch set 2 11/25/26, 13:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115442

  9. core-ci commented on patch set 2 11/25/26, 14:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115442

  10. core-ci voted on patch set 2 V +1 11/25/26, 14:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115442

  11. Benjamin Kott uploaded patch set 3 V +1 11/27/26, 01:41

  12. Benjamin Kott commented on patch set 3 11/27/26, 01:41

    Patch Set 3: Rebased onto current main and reviewed the change in depth. Thanks, the fix looks good to me. What changed compared to patch set 2: * Rebase: "[BUGFIX] Keep preview simulation on the error page" (2b54d06fd82) added tests to PageContentErrorHandlerTest in the meantime. The conflict was only in the imports and in the tests appended at the end of the class; both sides are kept. PageContentErrorHandler itself applied without conflict and keeps the preview parameters of that fix. * hiddenErrorPageIsShownToBackendUser now logs the backend user in with a real session cookie, as errorPageSubRequestKeepsPreviewSimulationOfBackendUser on main already does. Both tests share the new helper withBackendUserSession(). That way the regular authentication resolves the live workspace, the workaround with InternalRequestContext::withWorkspaceId(0) and its comment are gone, and the test exercises the same path as a real backend user. I checked that the test still fails without the change in PageContentErrorHandler. * typo3ErrorPageGetsContentSecurityPolicyThatAllowsItsInlineStyle asserts that the nonce is found in the body before it uses it, so a missing nonce fails with a clear message instead of the `?? ''` fallback. The production code and the commit message are unchanged. Run on the rebased patch set: functional tests (SQLite) for PageContentErrorHandlerTest (16 tests, 10 of them fail without the fix), frontend SiteHandling, core Error and core Site (2722 tests, green); cgl -n, checkIntegrityPhp, listExceptionCodes are green. PHPStan reports only an internal reflection error in SchedulerTaskRepository, unrelated to this change. The patch also applies cleanly to 14.3. Notes that I did not change, for you to decide: * Only the sub-request path logs a warning. When an external error page (errorContentSource is a URL) fails, the handler still answers silently with the TYPO3 error page. A warning there as well would help integrators in the same way; could also be a follow-up. * The fallback page is always HTML. ErrorController::handleError() answers a JSON response for `Accept: application/json`. That was the same before this change, just mentioning it. * PageContentErrorHandler in EXT:core now uses the @internal ContentSecurityPolicyHeaders of EXT:frontend. It already depends on Frontend\Http\Application, so this adds no new direction, but it is one more core-to-frontend reference.
  13. core-ci voted on patch set 3 V +1 11/27/26, 01:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115645

  14. Matthias Vogel uploaded patch set 4 V +1 11/27/26, 09:59

    Hi Benjamin, thank you for the improvements to the tests. 1. Warning for the external error page: Done in this patch set. When the external request fails, the handler now logs a warning with the URI. The warning also gives the status code or the error message of the request. Two new functional tests cover this. Also, the handler now gets its logger from LogManager in the constructor. It does not use LoggerAwareInterface and LoggerAwareTrait anymore. 2. Fallback page is always HTML: This was the same before this change. The old fallback was also an HTML response. A JSON answer for "Accept: application/json" is a new feature. I think it is out of scope for this bugfix. We can open a separate issue for it. 3. Core uses the @internal ContentSecurityPolicyHeaders of ext:frontend: I want to keep this for this bugfix. PageContentErrorHandler already depends on ext:frontend, because it uses Frontend\Http\Application for the sub-request. A clean core API for the Content-Security-Policy of an error response is a larger change. It should be a separate change.
  15. core-ci voted on patch set 4 V +1 11/27/26, 10:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115702

  16. Garvin Hicking voted on patch set 4 CR +1 V +1 11/27/26, 10:57

  17. Benni Mack voted on patch set 4 CR +2 V +2 11/28/26, 10:49

  18. Benni Mack merged patch set 5 11/28/26, 10:49