Skip to content

Commit b507973

Browse files
Merge branch '5.0' into 5.1
* 5.0: Fix test that fails on old distros Fix: compatibility with phpunit 9.3 [DoctrineBridge] work around Connection::ping() deprecation [MimeType] Duplicated MimeType due to PHP Bug [DI] fix parsing of argument type=binary in xml fix guessing form types for DateTime types fix handling typed properties as constraint options Fix the 'supports' method argument type of the security voter Use the driverConnection executeUpdate method
2 parents 8da253f + c6cce92 commit b507973

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Messenger/DoctrinePingConnectionMiddleware.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Messenger;
1313

14+
use Doctrine\DBAL\DBALException;
1415
use Doctrine\ORM\EntityManagerInterface;
1516
use Symfony\Component\Messenger\Envelope;
1617
use Symfony\Component\Messenger\Middleware\StackInterface;
@@ -36,7 +37,9 @@ private function pingConnection(EntityManagerInterface $entityManager)
3637
{
3738
$connection = $entityManager->getConnection();
3839

39-
if (!$connection->ping()) {
40+
try {
41+
$connection->query($connection->getDatabasePlatform()->getDummySelectSQL());
42+
} catch (DBALException $e) {
4043
$connection->close();
4144
$connection->connect();
4245
}

Tests/Messenger/DoctrinePingConnectionMiddlewareTest.php

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

1414
use Doctrine\DBAL\Connection;
15+
use Doctrine\DBAL\DBALException;
1516
use Doctrine\ORM\EntityManagerInterface;
1617
use Doctrine\Persistence\ManagerRegistry;
1718
use Symfony\Bridge\Doctrine\Messenger\DoctrinePingConnectionMiddleware;
@@ -47,8 +48,8 @@ protected function setUp(): void
4748
public function testMiddlewarePingOk()
4849
{
4950
$this->connection->expects($this->once())
50-
->method('ping')
51-
->willReturn(false);
51+
->method('getDatabasePlatform')
52+
->will($this->throwException(new DBALException()));
5253

5354
$this->connection->expects($this->once())
5455
->method('close')
@@ -65,6 +66,10 @@ public function testMiddlewarePingOk()
6566

6667
public function testMiddlewarePingResetEntityManager()
6768
{
69+
$this->connection->expects($this->once())
70+
->method('getDatabasePlatform')
71+
->will($this->throwException(new DBALException()));
72+
6873
$this->entityManager->expects($this->once())
6974
->method('isOpen')
7075
->willReturn(false)

0 commit comments

Comments
 (0)