-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Laravel quietly ignores Symfony's deprecations: @trigger_error() #40854
Comments
Some opt-in details on twigphp/Twig#2082 |
You can log deprecations, from symfony or any other vendor code, by setting up the deprecations log channel: https://laravel.com/docs/8.x/logging#logging-deprecation-warnings. |
No, you can't, because they never ever get past Laravel's error handler:
That's the problem..... |
I can confirm this issue. My feature tests use Since Symfony silences those deprecations the test doesn't fail while my expectation is for it to fail. So TLDR; use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
final class FooTest extends TestCase
{
use WithFaker;
public function testFoo(): void
{
$this->withoutDeprecationHandling();
$this->faker->name;
}
} Expected result is for the test to fail as Faker emits If I go into |
Laravel's
ALWAYS handle deprecations. The only reason they wouldn't get past |
Maybe instead of checking for a deprecation error inside the first framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php Lines 68 to 77 in afeb58d
We could check it before: public function handleError($level, $message, $file = '', $line = 0, $context = [])
{
if ($this->isDeprecation($level)) {
return $this->handleDeprecation($message, $file, $line);
}
if (error_reporting() & $level) {
throw new ErrorException($message, 0, $level, $file, $line);
}
} As the I tested locally with and without suppressing the EDIT: Somehow I missed this @rudiedirkx 's comment, which suggests the same: |
Fixed. |
Description:
The Symfony ecosystem triggers deprecations like this:
with the
@
to suppress error, to make deprecations opt-in. That's a decent idea, IF the app/framework's error handler CAN opt-in. The first thing Laravel's error handler does is:which means all of Symfony's deprecation triggers are always completely ignored. No opt-in possible.
I think Laravel shouldn't check for error suppression if it's a deprecation, because that's how Symfony does deprecations on purpose. This could work beautifully with
isDeprecation()
andhandleDeprecation()
, but it doesn't, and it's too early for the app'sHandler
to do/catch anything.Steps To Reproduce:
Trigger a deprecation error, anywhere in your app code, with any Laravel config:
Without the
@
it's reported to mydeprecations.log
, but with the@
it's quietly ignored. Symfony's standard is to do it with the@
, so I feel that should work.The text was updated successfully, but these errors were encountered: