-
Improvement
-
Resolution: Fixed
-
Minor
-
3.9.4, 3.10.1, 3.10.2, 3.10.3
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
MOODLE_311_STABLE
-
MDL_71012_master
-
Easy
-
We were trying to set up custom maintenance page, by returning a 503 status code from our web server when we want to turn on maintenance mode, and having our front-end display a custom page when it recieves a 503.
However, we found that when our web server was not set to return a 503, we were still seeing the maintenance page. It turned out the page we were trying to view was throwing an exception, and Moodle's exception handler (via bootstrap_renderer::early_error) was returning a 503, triggering our front-end to show the maintenance page, and preventing us from seeing the error message.
According to The standard, 503 is:
503 Service Unavailable
The server cannot handle the request (because it is overloaded or down for maintenance). Generally, this is a temporary state.
I believe that Moodle's use of this code for generic exceptions is incorrect. The fact that Moodle is generating exceptions shows that the service is available, but there is something wrong with it. I believe that Moodle should return a 500 Internal Server Error (and a useful error message) in this case, leaving 503 for its intended purpose.