Merge branch '5.1'
* 5.1: [Cache] fix parse error on PHP 5.5 [Cache] fix compat with doctrine/dbal v3 [Lock] fix compat with doctrine/dbal v3
This commit is contained in:
commit
880142ac40
@ -389,19 +389,19 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
|
|||||||
|
|
||||||
foreach ($values as $id => $data) {
|
foreach ($values as $id => $data) {
|
||||||
try {
|
try {
|
||||||
$stmt->execute();
|
$result = $stmt->execute();
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
|
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$result = $stmt->execute();
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
|
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$result = $stmt->execute();
|
||||||
}
|
}
|
||||||
if (null === $driver && !$stmt->rowCount()) {
|
if (null === $driver && !($result instanceof Result ? $result : $stmt)->rowCount()) {
|
||||||
try {
|
try {
|
||||||
$insertStmt->execute();
|
$insertStmt->execute();
|
||||||
} catch (DBALException $e) {
|
} catch (DBALException $e) {
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Lock\Store;
|
|||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use Doctrine\DBAL\DriverManager;
|
use Doctrine\DBAL\DriverManager;
|
||||||
|
use Doctrine\DBAL\Result;
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Lock\Exception\InvalidTtlException;
|
use Symfony\Component\Lock\Exception\InvalidTtlException;
|
||||||
@ -158,10 +159,10 @@ class PdoStore implements PersistingStoreInterface
|
|||||||
$stmt->bindValue(':id', $this->getHashedKey($key));
|
$stmt->bindValue(':id', $this->getHashedKey($key));
|
||||||
$stmt->bindValue(':token1', $uniqueToken);
|
$stmt->bindValue(':token1', $uniqueToken);
|
||||||
$stmt->bindValue(':token2', $uniqueToken);
|
$stmt->bindValue(':token2', $uniqueToken);
|
||||||
$stmt->execute();
|
$result = $stmt->execute();
|
||||||
|
|
||||||
// If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner
|
// If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner
|
||||||
if (!$stmt->rowCount() && !$this->exists($key)) {
|
if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this->exists($key)) {
|
||||||
throw new LockConflictedException();
|
throw new LockConflictedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,9 +192,9 @@ class PdoStore implements PersistingStoreInterface
|
|||||||
|
|
||||||
$stmt->bindValue(':id', $this->getHashedKey($key));
|
$stmt->bindValue(':id', $this->getHashedKey($key));
|
||||||
$stmt->bindValue(':token', $this->getUniqueToken($key));
|
$stmt->bindValue(':token', $this->getUniqueToken($key));
|
||||||
$stmt->execute();
|
$result = $stmt->execute();
|
||||||
|
|
||||||
return (bool) (method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn());
|
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
|
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
|
||||||
|
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use Doctrine\DBAL\Driver\ResultStatement;
|
|
||||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
use Doctrine\DBAL\Query\QueryBuilder;
|
use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||||
@ -144,7 +143,7 @@ class ConnectionTest extends TestCase
|
|||||||
return $queryBuilder;
|
return $queryBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getStatementMock($expectedResult): ResultStatement
|
private function getStatementMock($expectedResult)
|
||||||
{
|
{
|
||||||
$stmt = $this->createMock(Statement::class);
|
$stmt = $this->createMock(Statement::class);
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Transport;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Connection as DBALConnection;
|
use Doctrine\DBAL\Connection as DBALConnection;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
use Doctrine\DBAL\Driver\ResultStatement;
|
|
||||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||||
use Doctrine\DBAL\Query\QueryBuilder;
|
use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
@ -319,7 +318,7 @@ class Connection implements ResetInterface
|
|||||||
->from($this->configuration['table_name'], 'm');
|
->from($this->configuration['table_name'], 'm');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function executeQuery(string $sql, array $parameters = [], array $types = []): ResultStatement
|
private function executeQuery(string $sql, array $parameters = [], array $types = [])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$stmt = $this->driverConnection->executeQuery($sql, $parameters, $types);
|
$stmt = $this->driverConnection->executeQuery($sql, $parameters, $types);
|
||||||
|
Reference in New Issue
Block a user