[5.6] Add an empty error bag for HTTP exceptions #23139
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this PR, if you had a custom HTTP error page like 404.blade.php that happens to extend a master layout which uses the errors variable, you would have an exception stating that $errors is undefined instead of the custom HTTP error page.
Here are 2 typical scenarios of $errors usage in the master layout:
There is an open issue related to it, including steps to reproduce: #23133
The goal of this PR is to add the $errors variable for all HTTP exceptions. This is a behavior which is similar to the web middleware : \Illuminate\View\Middleware\ShareErrorsFromSession. This middleware binds $errors to the session errors if the latter is defined and binds $errors to an empty view error bag otherwise because it is more convenient for the developer who doesn't have to run checks for the presence of errors.
In this HTTP exception fix, we do not have the session store set, so the errors variable is always set to an empty view error bag, again because it is more convenient for the developer.