framework
framework copied to clipboard
Pre-rendered Maintenance Mode is not rendered as if it was in Maintenance Mode
- 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:
- Create a
resources/views/errors/503.blade.phpwith 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
- Run the command
php artisan down --render="errors::503". - View the application in a browser.
- 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.
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!
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
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.