framework icon indicating copy to clipboard operation
framework copied to clipboard

Pre-rendered Maintenance Mode is not rendered as if it was in Maintenance Mode

Open Cbrad24 opened this issue 3 years ago • 2 comments

  • Laravel Version: v9.38.0
  • PHP Version: v8.1.12
  • Database Driver & Version: Postgres

Description:

The pre-rendered maintenance mode using the php artisan down --render="errors::503" command does not show up as if it was actually in maintenance mode.

Steps To Reproduce:

  1. Create a resources/views/errors/503.blade.php with the following contents:
@extends('errors::minimal')

@if(App::isDownForMaintenance())
    @section('title', __('Down for Maintenance'))
    @section('code', '503')
    @section('message', __('Down for Maintenance'))
@else
    @section('title', __('Service Unavailable'))
    @section('code', '503')
    @section('message', __('Service Unavailable'))
@endif
  1. Run the command php artisan down --render="errors::503".
  2. View the application in a browser.
  3. You will see 'Service Unavailable' instead of desired output 'Down for Maintenance'. This only happens with the pre '--render' flag.

It would be nice to be able to differentiate between maintenance mode and otherwise to display a more detailed reason for a 503 error to the user without having to boot the entire framework.

Cbrad24 avatar Nov 21 '22 06:11 Cbrad24

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

github-actions[bot] avatar Nov 21 '22 13:11 github-actions[bot]

When the view is rendered, the framework is not yet in maintenance mode, i think you will have to use two views. The way it's done, with a file_exists check, App::isDownForMaintenance() cannot work with pre-rendering of the view.

You could do that do fix it :

@extends('errors::minimal')

@if(App::isDownForMaintenance() || implode(' ', $_SERVER['argv']) == "artisan down --render=errors::503")
    @section('title', __('Down for Maintenance'))
    @section('code', '503')
    @section('message', __('Down for Maintenance'))
@else
    @section('title', __('Service Unavailable'))
    @section('code', '503')
    @section('message', __('Service Unavailable'))
@endif

not really pretty but it works

lk77 avatar Nov 22 '22 08:11 lk77

As said on https://github.com/laravel/framework/pull/45131 this is a bit of an edge case and thus we're not going to take any action here, sorry.

driesvints avatar Dec 01 '22 10:12 driesvints