-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][HttpKernel] Configure ErrorHandler
on boot
#49275
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
[FrameworkBundle][HttpKernel] Configure ErrorHandler
on boot
#49275
Conversation
9ee0a03
to
d38ad05
Compare
d38ad05
to
aba5dbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks, I just have some minor comments
->tag('monolog.logger', ['channel' => 'php']) | ||
|
||
->set('debug.debug_handlers_listener', DebugHandlersListener::class) | ||
->args([ | ||
null, // Exception handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this is actually never set anywhere, it remains null
. Maybe it'd be best to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, let's remove it from this file (but keep the arg in the class just in case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/Symfony/Component/HttpKernel/Tests/Debug/ErrorHandlerConfiguratorTest.php
Outdated
Show resolved
Hide resolved
aba5dbb
to
21b00ce
Compare
21b00ce
to
26e6a56
Compare
Thank you @HypeMC. |
Currently the
ErrorHandler
is somewhat configured inFrameworkBundle::boot()
and then later fully inDebugHandlersListener::configure()
.symfony/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Lines 92 to 96 in 3e79a27
symfony/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php
Lines 70 to 144 in 3e79a27
However, I've noticed that there are some edge case when the handler doesn't get configured in time/at all.
One such example is when using the Sentry bundle. The bundle has its own error handler which gets registered when the Sentry client is instantiated. If you're using Sentry with Monolog the client gets instantiated when a Monolog logger is used. Since the
http_kernel
service requires a logger, the client gets instantiated before thekernel.request
event and, as a result, when theDebugHandlersListener
is trigger both$handler
and$this->earlyHandler
arenull
and the error handler is never configured properly.Another example when the handler is not configured in time is when an error occurs in a
kernel.request
listener that has a higher priority then theDebugHandlersListener
. In such cases the error handler's loggers are not yet configured and the errors are not logged properly.These cases were tested with
APP_DEBUG=0
since the error handler is registered earlier when debug is enabled.The idea of this PR is to configure the error handler as early as possible to prevent such edge cases from ever being able to happen. The error handler is now fully configured in
FrameworkBundle::boot()
.