@@ -55,8 +55,6 @@ public function rebootKernel(): void
5555 {
5656 $ this ->updatePersistentServices ();
5757
58- $ this ->persistDoctrineConnections ();
59-
6058 if ($ this ->kernel instanceof Kernel) {
6159 $ this ->ensureKernelShutdown ();
6260 $ this ->kernel ->boot ();
@@ -72,7 +70,28 @@ public function rebootKernel(): void
7270 protected function ensureKernelShutdown (): void
7371 {
7472 $ this ->kernel ->boot ();
75- $ this ->kernel ->shutdown ();
73+
74+ $ kernel = $ this ->kernel ;
75+ (function () use ($ kernel ): void {
76+ $ parameters = property_exists ($ this , 'parameters ' ) ? $ this ->parameters : null ;
77+ if (!is_array ($ parameters ) || !array_key_exists ('doctrine.connections ' , $ parameters )) {
78+ $ kernel ->shutdown ();
79+
80+ return ;
81+ }
82+
83+ $ connections = $ parameters ['doctrine.connections ' ];
84+ unset($ parameters ['doctrine.connections ' ]);
85+ $ this ->parameters = $ parameters ;
86+
87+ try {
88+ $ kernel ->shutdown ();
89+ } finally {
90+ $ parameters = $ this ->parameters ;
91+ $ parameters ['doctrine.connections ' ] = $ connections ;
92+ $ this ->parameters = $ parameters ;
93+ }
94+ })->call ($ kernel ->getContainer ());
7695 }
7796
7897 private function resolveContainer (): ContainerInterface
@@ -98,15 +117,6 @@ private function getProfiler(): ?Profiler
98117 return null ;
99118 }
100119
101- private function persistDoctrineConnections (): void
102- {
103- (function (): void {
104- if (property_exists ($ this , 'parameters ' ) && is_array ($ this ->parameters )) {
105- unset($ this ->parameters ['doctrine.connections ' ]);
106- }
107- })->call ($ this ->kernel ->getContainer ());
108- }
109-
110120 private function updatePersistentServices (): void
111121 {
112122 foreach ($ this ->persistentServices as $ name => $ _ ) {
0 commit comments