October: AJAX request errors not reported correctly when in maintenance mode

Created on 16 Aug 2019  路  5Comments  路  Source: octobercms/october

  • OctoberCMS Build: 1.0.457
  • PHP Version: 7.3.7
  • Database Engine: Not relevant
  • Plugins Installed: Not relevant

Description:

When firing AJAX requests when the OctoberCMS application is in maintenance mode you will not get a "good error", see screenshot for a backend example:

image (2)

Steps To Reproduce:

1) Put OctoberCMS in maintenance mode
2) Try to fire an AJAX request (without refreshing the webpage before you do this)
3) You'll see an "ugly" error

The issue is not only in the backend, it's also in the frontend.

Possible solution

The middleware responsible for doing this is:
vendor/october/rain/src/Foundation/Http/Middleware/CheckForMaintenanceMode.php.

It's loaded from the kernel:
vendor/october/rain/src/Foundation/Http/Kernel.php:30

The middleware will need an additional check for AJAX requests, we could put some code in the catch clause like:

if ($request->ajax()) {
    throw new SomeExceptionWhichGetsRenderedBetter('A better message');
}

Another good feature would be the possibility to disable or override the middleware, the only way to do this at the moment is by creating your own kernel.php and registering it in the bootstrap/app.php.

Completed Bug

Most helpful comment

@nathan-van-der-werf thanks for reporting! I've seen it already :)

All 5 comments

@nathan-van-der-werf thanks for reporting! I've seen it already :)

Ajax should be allowed on Maintenance mode. Like it was disscussed here: https://github.com/octobercms/october/issues/4258

Or this is that maintenance mode that puts down everything?

Ajax should be allowed on Maintenance mode. Like it was disscussed here: #4258

Or this is that maintenance mode that puts down everything?

It's the php artisan down (so the one putting the application / website "offline")

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see action on it, please respond and we will get the ball rolling.

@nathan-van-der-werf an ApplicationException gets handled nicely by the backend, you could give that a try and make a PR

Was this page helpful?
0 / 5 - 0 ratings