Skip to content

Commit fa661b5

Browse files
ro0NLnicolas-grekas
authored andcommitted
[Messenger] Fix DoctrineOpenTransactionLoggerMiddleware
1 parent 621dd96 commit fa661b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
class DoctrineOpenTransactionLoggerMiddleware extends AbstractDoctrineMiddleware
2727
{
2828
private $logger;
29+
/** @var bool */
30+
private $isHandling = false;
2931

3032
public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null, LoggerInterface $logger = null)
3133
{
@@ -36,6 +38,12 @@ public function __construct(ManagerRegistry $managerRegistry, string $entityMana
3638

3739
protected function handleForManager(EntityManagerInterface $entityManager, Envelope $envelope, StackInterface $stack): Envelope
3840
{
41+
if ($this->isHandling) {
42+
return $stack->next()->handle($envelope, $stack);
43+
}
44+
45+
$this->isHandling = true;
46+
3947
try {
4048
return $stack->next()->handle($envelope, $stack);
4149
} finally {
@@ -44,6 +52,7 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
4452
'message' => $envelope->getMessage(),
4553
]);
4654
}
55+
$this->isHandling = false;
4756
}
4857
}
4958
}

0 commit comments

Comments
 (0)