Skip to content

Commit d28330f

Browse files
bug #52075 [Messenger] Fix DoctrineOpenTransactionLoggerMiddleware (ro0NL)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Messenger] Fix DoctrineOpenTransactionLoggerMiddleware | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT When a message is routed via `sync://` we hit the middleware stack twice (meh, but OK). A side effect is we always get an error log due open transaction, even though it was closed properly. But it's an inner transaction. This solves it. Commits ------- fa661b5 [Messenger] Fix DoctrineOpenTransactionLoggerMiddleware
2 parents 621dd96 + fa661b5 commit d28330f

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy