Skip to content

Commit b8a5e48

Browse files
committed
bug #39025 [DoctrineBridge] Fix DBAL deprecations in middlewares (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [DoctrineBridge] Fix DBAL deprecations in middlewares | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Commits ------- 969da48 [DoctrineBridge] Fix DBAL deprecations in middlewares.
2 parents be8fd56 + 969da48 commit b8a5e48

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\Messenger;
1313

1414
use Doctrine\DBAL\DBALException;
15+
use Doctrine\DBAL\Exception;
1516
use Doctrine\ORM\EntityManagerInterface;
1617
use Symfony\Component\Messenger\Envelope;
1718
use Symfony\Component\Messenger\Middleware\StackInterface;
@@ -38,8 +39,8 @@ private function pingConnection(EntityManagerInterface $entityManager)
3839
$connection = $entityManager->getConnection();
3940

4041
try {
41-
$connection->query($connection->getDatabasePlatform()->getDummySelectSQL());
42-
} catch (DBALException $e) {
42+
$connection->executeQuery($connection->getDatabasePlatform()->getDummySelectSQL());
43+
} catch (DBALException | Exception $e) {
4344
$connection->close();
4445
$connection->connect();
4546
}

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrinePingConnectionMiddlewareTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\DBAL\Connection;
1515
use Doctrine\DBAL\DBALException;
16+
use Doctrine\DBAL\Exception;
1617
use Doctrine\ORM\EntityManagerInterface;
1718
use Doctrine\Persistence\ManagerRegistry;
1819
use Symfony\Bridge\Doctrine\Messenger\DoctrinePingConnectionMiddleware;
@@ -49,7 +50,7 @@ public function testMiddlewarePingOk()
4950
{
5051
$this->connection->expects($this->once())
5152
->method('getDatabasePlatform')
52-
->will($this->throwException(new DBALException()));
53+
->will($this->throwException(class_exists(Exception::class) ? new Exception() : new DBALException()));
5354

5455
$this->connection->expects($this->once())
5556
->method('close')
@@ -68,7 +69,7 @@ public function testMiddlewarePingResetEntityManager()
6869
{
6970
$this->connection->expects($this->once())
7071
->method('getDatabasePlatform')
71-
->will($this->throwException(new DBALException()));
72+
->will($this->throwException(class_exists(Exception::class) ? new Exception() : new DBALException()));
7273

7374
$this->entityManager->expects($this->once())
7475
->method('isOpen')

0 commit comments

Comments
 (0)