@@ -31,23 +31,25 @@ public function __construct(
31
31
parent ::__construct ($ kernel );
32
32
$ this ->followRedirects ();
33
33
$ this ->container = $ this ->getContainer ();
34
- $ this ->rebootKernel (); // Ensure the profiler exists
34
+ $ this ->rebootKernel ();
35
35
}
36
36
37
37
/** @param Request $request */
38
38
protected function doRequest (object $ request ): Response
39
39
{
40
- if ($ this ->hasPerformedRequest && $ this ->rebootable ) {
41
- $ this ->rebootKernel ();
42
- } else {
43
- $ this ->hasPerformedRequest = true ;
40
+ if ($ this ->rebootable ) {
41
+ if ($ this ->hasPerformedRequest ) {
42
+ $ this ->rebootKernel ();
43
+ } else {
44
+ $ this ->hasPerformedRequest = true ;
45
+ }
44
46
}
45
47
46
48
return parent ::doRequest ($ request );
47
49
}
48
50
49
51
/**
50
- * Reboot kernel
52
+ * Reboots the kernel.
51
53
*
52
54
* Services from the list of persistent services
53
55
* are updated from service container before kernel shutdown
@@ -64,8 +66,7 @@ public function rebootKernel(): void
64
66
}
65
67
66
68
$ this ->persistDoctrineConnections ();
67
- $ this ->kernel ->boot ();
68
- $ this ->kernel ->shutdown ();
69
+ $ this ->ensureKernelShutdown ();
69
70
$ this ->kernel ->boot ();
70
71
$ this ->container = $ this ->getContainer ();
71
72
@@ -82,6 +83,12 @@ public function rebootKernel(): void
82
83
}
83
84
}
84
85
86
+ protected function ensureKernelShutdown (): void
87
+ {
88
+ $ this ->kernel ->boot ();
89
+ $ this ->kernel ->shutdown ();
90
+ }
91
+
85
92
private function getContainer (): ?ContainerInterface
86
93
{
87
94
/** @var ContainerInterface $container */
0 commit comments