Skip to content

Navigation Menu

Sign in
Appearance settings

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 79686c6

Browse filesBrowse files
committed
Merge branch '4.4' into 5.1
* 4.4: fix compatibility with Doctrine DBAL 3
2 parents 941647f + 966dc58 commit 79686c6
Copy full SHA for 79686c6

File tree

Expand file treeCollapse file tree

6 files changed

+32
-13
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+32
-13
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/PdoAdapter.php
+3-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/PdoStore.php
+3-1Lines 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\Schema\Schema;
1920
use Symfony\Component\Lock\Exception\InvalidArgumentException;
2021
use Symfony\Component\Lock\Exception\InvalidTtlException;
@@ -126,7 +127,7 @@ public function save(Key $key)
126127

127128
try {
128129
$stmt->execute();
129-
} catch (DBALException $e) {
130+
} catch (DBALException | Exception $e) {
130131
// the lock is already acquired. It could be us. Let's try to put off.
131132
$this->putOffExpiration($key, $this->initialTtl);
132133
} catch (\PDOException $e) {
@@ -240,6 +241,7 @@ private function getConnection(): object
240241
*
241242
* @throws \PDOException When the table already exists
242243
* @throws DBALException When the table already exists
244+
* @throws Exception When the table already exists
243245
* @throws \DomainException When an unsupported PDO driver is used
244246
*/
245247
public function createTable(): void

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php
+13-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php
+4-2Lines 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;
@@ -121,6 +122,7 @@ public static function buildConfiguration(string $dsn, array $options = []): arr
121122
* @return string The inserted id
122123
*
123124
* @throws \Doctrine\DBAL\DBALException
125+
* @throws \Doctrine\DBAL\Exception
124126
*/
125127
public function send(string $body, array $headers, int $delay = 0): string
126128
{
@@ -220,7 +222,7 @@ public function ack(string $id): bool
220222
{
221223
try {
222224
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
223-
} catch (DBALException $exception) {
225+
} catch (DBALException | Exception $exception) {
224226
throw new TransportException($exception->getMessage(), 0, $exception);
225227
}
226228
}
@@ -229,7 +231,7 @@ public function reject(string $id): bool
229231
{
230232
try {
231233
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
232-
} catch (DBALException $exception) {
234+
} catch (DBALException | Exception $exception) {
233235
throw new TransportException($exception->getMessage(), 0, $exception);
234236
}
235237
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineReceiver.php
+7-6Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineSender.php
+2-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.