8000 Merge branch '5.1' into master · symfony/symfony@9323b75 · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9323b75

Browse files
committed
Merge branch '5.1' into master
* 5.1: fix compatibility with Doctrine DBAL 3
2 parents 7cb8ba5 + 79686c6 commit 9323b75

File tree

6 files changed

+32
-13
lines changed

6 files changed

+32
-13
lines changed

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\DBAL\Driver\Result as DriverResult;
1818
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
1919
use Doctrine\DBAL\DriverManager;
20+
use Doctrine\DBAL\Exception;
2021
use Doctrine\DBAL\Exception\TableNotFoundException;
2122
use Doctrine\DBAL\Schema\Schema;
2223
use Symfony\Component\Cache\Exception\InvalidArgumentException;
@@ -109,6 +110,7 @@ public function __construct($connOrDsn, string $namespace = '', int $defaultLife
109110
*
110111
* @throws \PDOException When the table already exists
111112
* @throws DBALException When the table already exists
113+
* @throws Exception When the table already exists
112114
* @throws \DomainException When an unsupported PDO driver is used
113115
*/
114116
public function createTable()
@@ -417,7 +419,7 @@ protected function doSave(array $values, int $lifetime)
417419
if (null === $driver && !($result instanceof DriverResult ? $result : $stmt)->rowCount()) {
418420
try {
419421
$insertStmt->execute();
420-
} catch (DBALException $e) {
422+
} catch (DBALException | Exception $e) {
421423
} catch (\PDOException $e) {
422424
// A concurrent write won, let it be
423425
}

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\DBAL\DBALException;
1616
use Doctrine\DBAL\Driver\Result;
1717
use Doctrine\DBAL\DriverManager;
18+
use Doctrine\DBAL\Exception;
1819
use Doctrine\DBAL\Exception\TableNotFoundException;
1920
use Doctrine\DBAL\Schema\Schema;
2021
use Symfony\Component\Lock\Exception\InvalidArgumentException;
@@ -145,7 +146,7 @@ public function save(Key $key)
145146
$this->createTable();
146147
}
147148
$stmt->execute();
148-
} catch (DBALException $e) {
149+
} catch (DBALException | Exception $e) {
149150
// the lock is already acquired. It could be us. Let's try to put off.
150151
$this->putOffExpiration($key, $this->initialTtl);
151152
} catch (\PDOException $e) {
@@ -259,6 +260,7 @@ private function getConnection(): object
259260
*
260261
* @throws \PDOException When the table already exists
261262
* @throws DBALException When the table already exists
263+
* @throws Exception When the table already exists
262264
* @throws \DomainException When an unsupported PDO driver is used
263265
*/
264266
public function createTable(): void

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

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

1414
use Doctrine\DBAL\Abstraction\Result;
1515
use Doctrine\DBAL\DBALException;
16+
use Doctrine\DBAL\Exception;
1617
use Doctrine\DBAL\Platforms\AbstractPlatform;
1718
use Doctrine\DBAL\Query\QueryBuilder;
1819
use Doctrine\DBAL\Schema\AbstractSchemaManager;
@@ -88,7 +89,12 @@ public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage()
8889
{
8990
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
9091
$driverConnection = $this->getDBALConnectionMock();
91-
$driverConnection->method('delete')->willThrowException(new DBALException());
92+
93+
if (class_exists(Exception::class)) {
94+
$driverConnection->method('delete')->willThrowException(new Exception());
95+
} else {
96+
$driverConnection->method('delete')->willThrowException(new DBALException());
97+
}
9298

9399
$connection = new Connection([], $driverConnection);
94100
$connection->ack('dummy_id');
@@ -98,7 +104,12 @@ public function testItThrowsATransportExceptionIfItCannotRejectMessage()
98104
{
99105
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
100106
$driverConnection = $this->getDBALConnectionMock();
101-
$driverConnection->method('delete')->willThrowException(new DBALException());
107+
108+
if (class_exists(Exception::class)) {
109+
$driverConnection->method('delete')->willThrowException(new Exception());
110+
} else {
111+
$driverConnection->method('delete')->willThrowException(new DBALException());
112+
}
102113

103114
$connection = new Connection([], $driverConnection);
104115
$connection->reject('dummy_id');

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Connection as DBALConnection;
1515
use Doctrine\DBAL\DBALException;
1616
use Doctrine\DBAL\Driver\Result;
17+
use Doctrine\DBAL\Exception;
1718
use Doctrine\DBAL\Exception\TableNotFoundException;
1819
use Doctrine\DBAL\Query\QueryBuilder;
1920
use Doctrine\DBAL\Schema\Comparator;
@@ -114,6 +115,7 @@ public static function buildConfiguration(string $dsn, array $options = []): arr
114115
* @return string The inserted id
115116
*
116117
* @throws \Doctrine\DBAL\DBALException
118+
* @throws \Doctrine\DBAL\Exception
117119
*/
118120
public function send(string $body, array $headers, int $delay = 0): string
119121
{
@@ -207,7 +209,7 @@ public function ack(string $id): bool
207209
{
208210
try {
209211
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
210-
} catch (DBALException $exception) {
212+
} catch (DBALException | Exception $exception) {
211213
throw new TransportException($exception->getMessage(), 0, $exception);
212214
}
213215
}
@@ -216,7 +218,7 @@ public function reject(string $id): bool
216218
{
217219
try {
218220
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
219-
} catch (DBALException $exception) {
221+
} catch (DBALException | Exception $exception) {
220222
throw new TransportException($exception->getMessage(), 0, $exception);
221223
}
222224
}

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineReceiver.php

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

1414
use Doctrine\DBAL\DBALException;
15+
use Doctrine\DBAL\Exception;
1516
use Doctrine\DBAL\Exception\RetryableException;
1617
use Symfony\Component\Messenger\Envelope;
1718
use Symfony\Component\Messenger\Exception\LogicException;
@@ -58,7 +59,7 @@ public function get(): iterable
5859
}
5960

6061
return [];
61-
} catch (DBALException $exception) {
62+
} catch (DBALException | Exception $exception) {
6263
throw new TransportException($exception->getMessage(), 0, $exception);
6364
}
6465

@@ -76,7 +77,7 @@ public function ack(Envelope $envelope): void
7677
{
7778
try {
7879
$this->connection->ack($this->findDoctrineReceivedStamp($envelope)->getId());
79-
} catch (DBALException $exception) {
80+
} catch (DBALException | Exception $exception) {
8081
throw new TransportException($exception->getMessage(), 0, $exception);
8182
}
8283
}
@@ -88,7 +89,7 @@ public function reject(Envelope $envelope): void
8889
{
8990
try {
9091
$this->connection->reject($this->findDoctrineReceivedStamp($envelope)->getId());
91-
} catch (DBALException $exception) {
92+
} catch (DBALException | Exception $exception) {
9293
throw new TransportException($exception->getMessage(), 0, $exception);
9394
}
9495
}
@@ -100,7 +101,7 @@ public function getMessageCount(): int
100101
{
101102
try {
102103
return $this->connection->getMessageCount();
103-
} catch (DBALException $exception) {
104+
} catch (DBALException | Exception $exception) {
104105
throw new TransportException($exception->getMessage(), 0, $exception);
105106
}
106107
}
@@ -112,7 +113,7 @@ public function all(int $limit = null): iterable
112113
{
113114
try {
114115
$doctrineEnvelopes = $this->connection->findAll($limit);
115-
} catch (DBALException $exception) {
116+
} catch (DBALException | Exception $exception) {
116117
throw new TransportException($exception->getMessage(), 0, $exception);
117118
}
118119

@@ -128,7 +129,7 @@ public function find($id): ?Envelope
128129
{
129130
try {
130131
$doctrineEnvelope = $this->connection->find($id);
131-
} catch (DBALException $exception) {
132+
} catch (DBALException | Exception $exception) {
132133
throw new TransportException($exception->getMessage(), 0, $exception);
133134
}
134135

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineSender.php

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

1414
use Doctrine\DBAL\DBALException;
15+
use Doctrine\DBAL\Exception;
1516
use Symfony\Component\Messenger\Envelope;
1617
use Symfony\Component\Messenger\Exception\TransportException;
1718
use Symfony\Component\Messenger\Stamp\DelayStamp;
@@ -47,7 +48,7 @@ public function send(Envelope $envelope): Envelope
4748

4849
try {
4950
$id = $this->connection->send($encodedMessage['body'], $encodedMessage['headers'] ?? [], $delay);
50-
} catch (DBALException $exception) {
51+
} catch (DBALException | Exception $exception) {
5152
throw new TransportException($exception->getMessage(), 0, $exception);
5253
}
5354

0 commit comments

Comments
 (0)
0