Skip to content

Commit 02e8c6b

Browse files
committed
Fix security context missing in Doctrine entity listeners after kernel reboot
Fixes #34
1 parent 81c0365 commit 02e8c6b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Codeception/Lib/Connector/Symfony.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Codeception\Lib\Connector;
66

7+
use Doctrine\ORM\EntityManagerInterface;
8+
use Doctrine\Persistence\ManagerRegistry;
79
use InvalidArgumentException;
810
use Symfony\Component\DependencyInjection\ContainerInterface;
911
use Symfony\Component\HttpFoundation\Response;
@@ -55,7 +57,7 @@ public function rebootKernel(): void
5557
{
5658
$this->updatePersistentServices();
5759

58-
$this->persistDoctrineConnections();
60+
$this->keepDoctrineConnectionsOpen();
5961

6062
if ($this->kernel instanceof Kernel) {
6163
$this->ensureKernelShutdown();
@@ -96,7 +98,7 @@ private function getProfiler(): ?Profiler
9698
return $profiler instanceof Profiler ? $profiler : null;
9799
}
98100

99-
private function persistDoctrineConnections(): void
101+
private function keepDoctrineConnectionsOpen(): void
100102
{
101103
(function (): void {
102104
if (property_exists($this, 'parameters') && is_array($this->parameters)) {
@@ -117,6 +119,9 @@ private function updatePersistentServices(): void
117119
private function injectPersistentServices(): void
118120
{
119121
foreach ($this->persistentServices as $name => $service) {
122+
if ($service instanceof EntityManagerInterface || $service instanceof ManagerRegistry) {
123+
continue;
124+
}
120125
try {
121126
$this->container->set($name, $service);
122127
} catch (InvalidArgumentException $e) {

0 commit comments

Comments
 (0)