33
33
*/
34
34
class DebugHandlersListener implements EventSubscriberInterface
35
35
{
36
+ private $ earlyHandler ;
36
37
private $ exceptionHandler ;
37
38
private $ logger ;
38
39
private $ levels ;
@@ -53,6 +54,10 @@ class DebugHandlersListener implements EventSubscriberInterface
53
54
*/
54
55
public function __construct (callable $ exceptionHandler = null , LoggerInterface $ logger = null , $ levels = \E_ALL , ?int $ throwAt = \E_ALL , bool $ scream = true , $ fileLinkFormat = null , bool $ scope = true )
55
56
{
57
+ $ handler = set_exception_handler ('var_dump ' );
58
+ $ this ->earlyHandler = \is_array($ handler ) ? $ handler [0 ] : null ;
59
+ restore_exception_handler ();
60
+
56
61
$ this ->exceptionHandler = $ exceptionHandler ;
57
62
$ this ->logger = $ logger ;
58
63
$ this ->levels = null === $ levels ? \E_ALL : $ levels ;
@@ -73,12 +78,26 @@ public function configure(Event $event = null)
73
78
if (!$ event instanceof KernelEvent ? !$ this ->firstCall : !$ event ->isMasterRequest ()) {
74
79
return ;
75
80
}
76
- $ this ->firstCall = $ this ->hasTerminatedWithException = false ;
77
81
78
82
$ handler = set_exception_handler ('var_dump ' );
79
83
$ handler = \is_array ($ handler ) ? $ handler [0 ] : null ;
80
84
restore_exception_handler ();
81
85
86
+ if (!$ handler instanceof ErrorHandler && !$ handler instanceof LegacyErrorHandler) {
87
+ $ handler = $ this ->earlyHandler ;
88
+ }
89
+
90
+ if ($ handler !== $ this ->earlyHandler ) {
91
+ set_exception_handler ('var_dump ' );
92
+ try {
93
+ $ this ->configure ($ event );
94
+ } finally {
95
+ restore_exception_handler ();
96
+ }
97
+ }
98
+
99
+ $ this ->firstCall = $ this ->hasTerminatedWithException = false ;
100
+
82
101
if ($ this ->logger || null !== $ this ->throwAt ) {
83
102
if ($ handler instanceof ErrorHandler || $ handler instanceof LegacyErrorHandler) {
84
103
if ($ this ->logger ) {
0 commit comments