Skip to content

Commit 01cfa3e

Browse files
Restore doctrine.connections after kernel shutdown (#244)
* Fix restore doctrine connections after kernel reboot
1 parent 558c038 commit 01cfa3e

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

src/Codeception/Lib/Connector/Symfony.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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,20 @@ 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+
if (!property_exists($this, 'parameters') || !is_array($this->parameters)) {
77+
$kernel->shutdown();
78+
return;
79+
}
80+
$connections = $this->parameters['doctrine.connections'] ?? null;
81+
unset($this->parameters['doctrine.connections']);
82+
$kernel->shutdown();
83+
if ($connections !== null) {
84+
$this->parameters['doctrine.connections'] = $connections;
85+
}
86+
})->call($kernel->getContainer());
7687
}
7788

7889
private function resolveContainer(): ContainerInterface
@@ -98,15 +109,6 @@ private function getProfiler(): ?Profiler
98109
return null;
99110
}
100111

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-
110112
private function updatePersistentServices(): void
111113
{
112114
foreach ($this->persistentServices as $name => $_) {

0 commit comments

Comments
 (0)