Merge branch '5.1' into master
* 5.1: fix compatibility with Doctrine DBAL 3
This commit is contained in:
commit
9323b75603
@ -17,6 +17,7 @@ use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result as DriverResult;
|
||||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
@ -109,6 +110,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
|
||||
*
|
||||
* @throws \PDOException When the table already exists
|
||||
* @throws DBALException When the table already exists
|
||||
* @throws Exception When the table already exists
|
||||
* @throws \DomainException When an unsupported PDO driver is used
|
||||
*/
|
||||
public function createTable()
|
||||
@ -417,7 +419,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
|
||||
if (null === $driver && !($result instanceof DriverResult ? $result : $stmt)->rowCount()) {
|
||||
try {
|
||||
$insertStmt->execute();
|
||||
} catch (DBALException $e) {
|
||||
} catch (DBALException | Exception $e) {
|
||||
} catch (\PDOException $e) {
|
||||
// A concurrent write won, let it be
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
||||
@ -145,7 +146,7 @@ class PdoStore implements PersistingStoreInterface
|
||||
$this->createTable();
|
||||
}
|
||||
$stmt->execute();
|
||||
} catch (DBALException $e) {
|
||||
} catch (DBALException | Exception $e) {
|
||||
// the lock is already acquired. It could be us. Let's try to put off.
|
||||
$this->putOffExpiration($key, $this->initialTtl);
|
||||
} catch (\PDOException $e) {
|
||||
@ -259,6 +260,7 @@ class PdoStore implements PersistingStoreInterface
|
||||
*
|
||||
* @throws \PDOException When the table already exists
|
||||
* @throws DBALException When the table already exists
|
||||
* @throws Exception When the table already exists
|
||||
* @throws \DomainException When an unsupported PDO driver is used
|
||||
*/
|
||||
public function createTable(): void
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
|
||||
|
||||
use Doctrine\DBAL\Abstraction\Result;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||
@ -88,7 +89,12 @@ class ConnectionTest extends TestCase
|
||||
{
|
||||
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
$driverConnection->method('delete')->willThrowException(new DBALException());
|
||||
|
||||
if (class_exists(Exception::class)) {
|
||||
$driverConnection->method('delete')->willThrowException(new Exception());
|
||||
} else {
|
||||
$driverConnection->method('delete')->willThrowException(new DBALException());
|
||||
}
|
||||
|
||||
$connection = new Connection([], $driverConnection);
|
||||
$connection->ack('dummy_id');
|
||||
@ -98,7 +104,12 @@ class ConnectionTest extends TestCase
|
||||
{
|
||||
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
$driverConnection->method('delete')->willThrowException(new DBALException());
|
||||
|
||||
if (class_exists(Exception::class)) {
|
||||
$driverConnection->method('delete')->willThrowException(new Exception());
|
||||
} else {
|
||||
$driverConnection->method('delete')->willThrowException(new DBALException());
|
||||
}
|
||||
|
||||
$connection = new Connection([], $driverConnection);
|
||||
$connection->reject('dummy_id');
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Transport;
|
||||
use Doctrine\DBAL\Connection as DBALConnection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Doctrine\DBAL\Schema\Comparator;
|
||||
@ -114,6 +115,7 @@ class Connection implements ResetInterface
|
||||
* @return string The inserted id
|
||||
*
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
*/
|
||||
public function send(string $body, array $headers, int $delay = 0): string
|
||||
{
|
||||
@ -207,7 +209,7 @@ class Connection implements ResetInterface
|
||||
{
|
||||
try {
|
||||
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
}
|
||||
@ -216,7 +218,7 @@ class Connection implements ResetInterface
|
||||
{
|
||||
try {
|
||||
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Messenger\Bridge\Doctrine\Transport;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Exception\RetryableException;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\Exception\LogicException;
|
||||
@ -58,7 +59,7 @@ class DoctrineReceiver implements ReceiverInterface, MessageCountAwareInterface,
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
|
||||
@ -76,7 +77,7 @@ class DoctrineReceiver implements ReceiverInterface, MessageCountAwareInterface,
|
||||
{
|
||||
try {
|
||||
$this->connection->ack($this->findDoctrineReceivedStamp($envelope)->getId());
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
}
|
||||
@ -88,7 +89,7 @@ class DoctrineReceiver implements ReceiverInterface, MessageCountAwareInterface,
|
||||
{
|
||||
try {
|
||||
$this->connection->reject($this->findDoctrineReceivedStamp($envelope)->getId());
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
}
|
||||
@ -100,7 +101,7 @@ class DoctrineReceiver implements ReceiverInterface, MessageCountAwareInterface,
|
||||
{
|
||||
try {
|
||||
return $this->connection->getMessageCount();
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
}
|
||||
@ -112,7 +113,7 @@ class DoctrineReceiver implements ReceiverInterface, MessageCountAwareInterface,
|
||||
{
|
||||
try {
|
||||
$doctrineEnvelopes = $this->connection->findAll($limit);
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
|
||||
@ -128,7 +129,7 @@ class DoctrineReceiver implements ReceiverInterface, MessageCountAwareInterface,
|
||||
{
|
||||
try {
|
||||
$doctrineEnvelope = $this->connection->find($id);
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Messenger\Bridge\Doctrine\Transport;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\Exception\TransportException;
|
||||
use Symfony\Component\Messenger\Stamp\DelayStamp;
|
||||
@ -47,7 +48,7 @@ class DoctrineSender implements SenderInterface
|
||||
|
||||
try {
|
||||
$id = $this->connection->send($encodedMessage['body'], $encodedMessage['headers'] ?? [], $delay);
|
||||
} catch (DBALException $exception) {
|
||||
} catch (DBALException | Exception $exception) {
|
||||
throw new TransportException($exception->getMessage(), 0, $exception);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user