Review main Merged

92750[FEATURE] Add generic error action for HTTP status codes in ErrorController

Torben Hansen CR +2 V +2 Normal +117 −23 updated 03/04/26, 08:38

Commit message

The `ErrorController` does currently contain several
methods to create error pages. All methods are bound to
their specific HTTP status code and are used in TYPO3
and extensions to create PSR-7 response objects when
errors occurred. Additionally, all methods resolve
a possible configured site error handling which allows
site administrators to configure a dedicated error
handling (e.g. render Fluid template) for a given status
code.

The current implementation of the methods are however
not always correct in case of the shown error message,
because all methods use the same title and message.
As an example, a 503 error for `pageUnavailable_force`
returns a 503 HTTP response, but the text shown is
"Page Not Found".

Additionally, the class is limited to only handle 404,
403, 500 and 503 errors.

This change adds the new method `customErrorAction`, which
allows flexible error handling for custom HTTP codes.

Additionally, the existing methods have been improved to
provide a better title and message for the current error
handled.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • Anja Leichsenring +1
    • Josua Vogel +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Anja Leichsenring +1
    • Josua Vogel +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 3647

Show 1422 earlier messages
  1. Torben Hansen uploaded patch set 1 02/09/26, 10:07

  2. core-ci voted on patch set 1 V +1 02/09/26, 10:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95456

  3. Torben Hansen marked it work in progress 02/09/26, 10:26

  4. Torben Hansen updated the commit message in patch set 2 V +1 02/09/26, 10:26

  5. core-ci voted on patch set 2 V +1 02/09/26, 10:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95458

  6. Torben Hansen uploaded patch set 3 V +1 02/09/26, 18:28

  7. Torben Hansen marked it ready for review 02/09/26, 18:29

  8. core-ci voted on patch set 3 V +1 02/09/26, 18:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95482

  9. Anja Leichsenring updated the commit message in patch set 4 V +1 02/09/26, 19:22

  10. Anja Leichsenring uploaded patch set 5 02/09/26, 19:29

  11. core-ci voted on patch set 4 V +1 02/09/26, 19:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95485

  12. Anja Leichsenring commented on patch set 5 02/09/26, 19:31

    ErrorController.php:149

    why did you settle for two variables holding 'reason'? Would it at least make sense to put the single reason into the array if not handed over and not empty?
  13. core-ci voted on patch set 5 V +1 02/09/26, 19:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95486

  14. Simon Schaufelberger commented on patch set 5 02/09/26, 23:01

    As an...
  15. Anja Leichsenring updated the commit message in patch set 6 V +1 02/10/26, 05:27

  16. Anja Leichsenring commented on patch set 6 02/10/26, 05:27

    Reply

    Done
  17. core-ci voted on patch set 6 V +1 02/10/26, 05:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95523

  18. Torben Hansen uploaded patch set 7 V +1 02/11/26, 08:02

  19. Torben Hansen commented on patch set 7 02/11/26, 08:10

    ErrorController.php:149 Reply

    I renamed one of the variables to be more clear what it is used for and also added a new doc comment to clarify, what the `$reasons` array is used for. Basically, `$reasons` is only used in TYPO3 core in site error handlers to determine, if the error handler is responsible. The array can have several keys like e.g. `code` with a `PageAccessFailureReasons` or `sub_section` with some additonal information. This is some kind of unfortunate, but I have no idea how to improve this without being breaking.
  20. core-ci voted on patch set 7 V -1 02/11/26, 08:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95601

  21. Torben Hansen rebased onto patch set 8 V -1 02/11/26, 08:39

  22. core-ci voted on patch set 8 V +1 02/11/26, 08:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95604

  1. Anja Leichsenring commented on patch set 8 CR +1 V +1 02/11/26, 19:39

    ErrorController.php:149 Reply

    Acknowledged
  2. Georg Ringer commented on patch set 8 02/11/26, 21:33

    if it is a feature we need a feature.rst
  3. Oliver Klee voted on patch set 8 CR +1 02/11/26, 23:15

  4. Torben Hansen uploaded patch set 9 CR +1 V +1 02/14/26, 10:49

  5. Torben Hansen commented on patch set 9 02/14/26, 10:49

    Reply

    Good catch, I completely forgot the feature RST.
  6. core-ci voted on patch set 9 V +1 02/14/26, 11:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95882

  7. Oliver Klee voted on patch set 9 CR +1 02/14/26, 12:19

  8. Simon Schaufelberger commented on patch set 9 02/14/26, 12:22

    Feature-108904-AddGenericErrorActionForCustomHTTPStatusCodesInErrorController.rst:15

    I don't know if it's relevant but there is a space after `:php:`
  9. Torben Hansen commented on patch set 10 CR +1 V +1 02/14/26, 12:40

    Published edit on patch set 9.
  10. Torben Hansen commented on patch set 10 02/14/26, 12:40

    Feature-108904-AddGenericErrorActionForCustomHTTPStatusCodesInErrorController.rst:15 Reply

    Done
  11. core-ci voted on patch set 10 V +1 02/14/26, 12:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95890

  12. Simon Schaufelberger voted on patch set 10 CR +1 V +1 02/14/26, 12:50

  13. Oliver Klee voted on patch set 10 CR +1 02/14/26, 12:54

  14. Anja Leichsenring voted on patch set 10 CR +1 V +1 02/15/26, 05:34

  15. Anja Leichsenring commented on patch set 10 CR 0 02/16/26, 16:38

    Actually, why do you deprecate a protected method in ErrorController? This one should not be overridden or directly called in userland code. To give credit where it is due: Benni spotted it. As far as I am concerned, the feature.rst is sufficient and we don't need any formal deprecation for handleDefaultError().
  16. Torben Hansen commented on patch set 10 02/16/26, 17:07

    Reply

    Thanks for the feedback. So is it ok then to remove the function completely?
  17. Anja Leichsenring commented on patch set 10 02/16/26, 18:08

    Reply

    yes, that should be fine. Protected methods are not part of public API.
  18. Benni Mack uploaded patch set 11 CR +1 V +1 02/27/26, 19:09

  19. Benni Mack commented on patch set 11 02/27/26, 19:09

    Reply

    Done
  20. core-ci voted on patch set 11 V +1 02/27/26, 19:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96991

  21. Oliver Klee voted on patch set 11 CR +1 02/27/26, 19:43

  22. Anja Leichsenring voted on patch set 11 CR +1 V +1 03/04/26, 08:33

  23. Josua Vogel voted on patch set 11 CR +1 V +1 03/04/26, 08:34

  24. Garvin Hicking voted on patch set 11 CR +2 V +2 03/04/26, 08:37

  25. Garvin Hicking merged patch set 12 03/04/26, 08:38