-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] Logs deprecations instead of treating them as exceptions #39219
Conversation
How services like bugsnag/sentry would behave after this change? |
No changes required. Deprecations shouldn't be sent to those tools. They are error monitoring, not logging. |
@nunomaduro isn't this a BC break? For example, some users asserting in their test cases that deprecation warning is thrown, but after upgrading framework their tests will fail |
Example: I found test case in one open-source project that is failing now due to this change, find the link below |
@sergiy-petrov We should see this as a bug fix, to be honest. Laravel should not throw exceptions on deprecations to begin with. |
@nunomaduro so if this is a bug fix, is this gonna be merged into 6.x? |
@sergiy-petrov no this was for php 8.1 specifically. |
This pull request changes the way Laravel's exception handler treats PHP deprecations.
Until today, Laravel always turn
E_DEPRECATION
orE_USER_DEPRECATION
level errors into exceptions. In other words, if we were to usestr_contains('', null)
in PHP 8.1, Laravel would convert that deprecation into an Error Exception that gets reported on the Exception Handler, and rendered on the browser.This pull request - just like Symfony - proposes that we start to ignore PHP deprecations and userland deprecations. Meaning that deprecations like
str_contains('', null)
in PHP 8.1 would not cause the program to stop. So, by default, if this pull request gets merged, no error exceptions appear on the browser or on the logger.This pull request also introduces a new
deprecations
log channel that can be configured by the user. This channel, uses thenull
driver by default, yet the user can configure a real driver like so:Of course, this pull request also configures PHPUnit differently, using the
convertDeprecationsToExceptions
flag so deprecations don't get treated as exceptions on tests.If this pull request gets merged, changes will be necessary on:
config/logging.php
, bump framework version, and phpunit version.config/logging.php
, bump framework version, and phpunit version.