Skip to content

[Improvement] Init: Introduce ErrorResponder (first usage: handle ilCtrl routing errors as HTTP 404)#11110

Open
fhelfer wants to merge 6 commits intoILIAS-eLearning:trunkfrom
fhelfer:improvement/init/ctrl-error-handling
Open

[Improvement] Init: Introduce ErrorResponder (first usage: handle ilCtrl routing errors as HTTP 404)#11110
fhelfer wants to merge 6 commits intoILIAS-eLearning:trunkfrom
fhelfer:improvement/init/ctrl-error-handling

Conversation

@fhelfer
Copy link
Contributor

@fhelfer fhelfer commented Feb 12, 2026

Summary

  • Introduces a centralised ErrorController (ILIAS\Init\ErrorController) that renders error pages with proper HTTP status codes using the UI-Framework MessageBox, replacing duplicated error-rendering logic across ilias.php and error.php.
  • Catches ilCtrlException and any Throwable with "ilCtrl" in the message during request dispatching and responds with HTTP 404 instead of redirecting (which previously caused cascading requests and separate log files).
  • Refactors error.php to delegate page rendering to the ErrorController (HTTP 500), keeping only the error.php-specific session cleanup in place.
  • Adds language variables http_404_not_found and http_500_internal_server_error (DE/EN).

Motivation

ilCtrl-related exceptions are semantical routing/dispatching problems. Previously, these caused redirects to error.php or the ILIAS base URL in production, generating cascading requests and individual log files — unhelpful for administrators and monitoring. Requests causing these issues are often related to any kind of bots/client automation (AI, Search Engines, Hack Attempts). The additional I/O (the dedicated log file, if enabled, and the subsequent HTTP request) can also lead to performance issues on platforms with high traffic/many concurrent users.

This change returns a clean HTTP 404 response directly, which is the correct semantic for "this route could not be resolved".

The changes also address the issue described in: https://mantis.ilias.de/view.php?id=45455

@fhelfer fhelfer added improvement php Pull requests that update Php code css/html Pull requests that propose changes to CSS/SCSS or HTML files. labels Feb 12, 2026
@thibsy thibsy added the translations Pull requests that propose changes to ILIAS language files. label Feb 12, 2026
@mjansenDatabay mjansenDatabay changed the title [Improvement] Init: Introduce ErrorController to handle ilCtrl routing errors as HTTP 404 [Improvement] Init: Introduce ErrorResponder (first usage: handle ilCtrl routing errors as HTTP 404) Feb 13, 2026
}

if (!headers_sent()) {
http_response_code(StatusCode::HTTP_INTERNAL_SERVER_ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is: Can we always assume that should result in an HTTP 502 status code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

css/html Pull requests that propose changes to CSS/SCSS or HTML files. improvement php Pull requests that update Php code translations Pull requests that propose changes to ILIAS language files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants