Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling
  [Translation] Fix CSV escape char in `CsvFileLoader` on PHP >= 7.4
  [DoctrineBridge] fix messenger bus dispatch inside an active transaction
  [HttpFoundation] Add tests for uncovered sections
  treat uninitialized properties referenced by property paths as null
  properly set up constraint options
  [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations
  [Core] Fix & Enhance security arabic translation.
  • Loading branch information
nicolas-grekas committed Jul 26, 2024
2 parents 64d024f + 009d870 commit 0de9662
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Messenger/DoctrineOpenTransactionLoggerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
}

$this->isHandling = true;
$initialTransactionLevel = $entityManager->getConnection()->getTransactionNestingLevel();

try {
return $stack->next()->handle($envelope, $stack);
} finally {
if ($entityManager->getConnection()->isTransactionActive()) {
if ($entityManager->getConnection()->getTransactionNestingLevel() > $initialTransactionLevel) {
$this->logger?->error('A handler opened a transaction but did not close it.', [
'message' => $envelope->getMessage(),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function log($level, $message, $context = []): void

public function testMiddlewareWrapsInTransactionAndFlushes()
{
$this->connection->expects($this->exactly(1))
->method('isTransactionActive')
->willReturn(true, true, false)
$this->connection->expects($this->exactly(2))
->method('getTransactionNestingLevel')
->willReturn(0, 1)
;

$this->middleware->handle(new Envelope(new \stdClass()), $this->getStackMock());
Expand Down

0 comments on commit 0de9662

Please sign in to comment.