@@ -31,7 +31,7 @@ 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 */
@@ -47,7 +47,7 @@ protected function doRequest(object $request): Response
47
47
}
48
48
49
49
/**
50
- * Reboot kernel
50
+ * Reboots the kernel.
51
51
*
52
52
* Services from the list of persistent services
53
53
* are updated from service container before kernel shutdown
@@ -64,8 +64,7 @@ public function rebootKernel(): void
64
64
}
65
65
66
66
$ this ->persistDoctrineConnections ();
67
- $ this ->kernel ->boot ();
68
- $ this ->kernel ->shutdown ();
67
+ $ this ->ensureKernelShutdown ();
69
68
$ this ->kernel ->boot ();
70
69
$ this ->container = $ this ->getContainer ();
71
70
@@ -82,6 +81,18 @@ public function rebootKernel(): void
82
81
}
83
82
}
84
83
84
+ protected function ensureKernelShutdown (): void
85
+ {
86
+ $ this ->kernel ->boot ();
87
+ $ container = $ this ->kernel ->getContainer ();
88
+
89
+ if ($ container ->has ('services_resetter ' )) {
90
+ $ container ->get ('services_resetter ' );
91
+ }
92
+
93
+ $ this ->kernel ->shutdown ();
94
+ }
95
+
85
96
private function getContainer (): ?ContainerInterface
86
97
{
87
98
/** @var ContainerInterface $container */
@@ -120,7 +131,9 @@ private function persistDoctrineConnections(): void
120
131
}
121
132
122
133
$ reflectedContainer = new ReflectionClass ($ publicContainer );
123
- $ reflectionTarget = $ reflectedContainer ->hasProperty ('parameters ' ) ? $ publicContainer : $ publicContainer ->getParameterBag ();
134
+ $ reflectionTarget = $ reflectedContainer ->hasProperty ('parameters ' )
135
+ ? $ publicContainer
136
+ : $ publicContainer ->getParameterBag ();
124
137
125
138
$ reflectedParameters = new ReflectionProperty ($ reflectionTarget , 'parameters ' );
126
139
$ reflectedParameters ->setAccessible (true );
0 commit comments