From 0aaacc446a00c72864ce55f044c7c818c9f2f949 Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Tue, 23 Sep 2025 14:01:55 +1000 Subject: [PATCH] MDL-86494 router: Display error details only when debugging is on --- lib/classes/router.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/classes/router.php b/lib/classes/router.php index 3a5e70bea0a..f1f3a0e9655 100644 --- a/lib/classes/router.php +++ b/lib/classes/router.php @@ -198,11 +198,14 @@ class router { * Add the Error Handling Middleware to the RouteGroup. */ protected function add_error_handler_middleware(): void { + global $CFG; + // Display error details only when debugging is on. + $displayerrordetails = !empty($CFG->debugdisplay); // Add the Error Handling Middleware and configure it to show Moodle Errors for HTML pages. $errormiddleware = new ErrorMiddleware( $this->app->getCallableResolver(), $this->app->getResponseFactory(), - displayErrorDetails: true, + displayErrorDetails: $displayerrordetails, logErrors: true, logErrorDetails: true, );