[5.6] Let Exception Handler do the reporting #24864
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.
When using the API Guard on
auth.php
, Laravel will try to authenticate the user through the Authorization Header.The User Provider can be Eloquent, in which case it will require a valid database connection.
The problem happens when the database connection configuration is wrong (username, password, database, etc) and the Auth Provider tries to reach for the database to authenticate the User.
Since the database is wrong, an exception will be thrown. However, the Handler will try to load the
Context
from the Auth Guard as stated here: https://github.com/laravel/framework/blob/5.6/src/Illuminate/Foundation/Exceptions/Handler.php#L151-L153.The Auth Guard will try to reach for the Database to load the User, which again will throw an exception, which will try to load the Context, which will go to the Database until PHP Max Allowed Memory gets exhausted.
This pull request changes the ConnectionFactory to just rely on the default Exception Handler instead of trying to force-log an exception itself, thus avoiding an infinite loop.