Merge branch '5.0' into 5.1

* 5.0:
  [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:
Nicolas Grekas 2020-06-09 14:11:32 +02:00
commit d5ff9e7d81
4 changed files with 11 additions and 12 deletions

View File

@ -389,19 +389,19 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
foreach ($values as $id => $data) {
try {
$stmt->execute();
$result = $stmt->execute();
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt->execute();
$result = $stmt->execute();
} catch (\PDOException $e) {
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt->execute();
$result = $stmt->execute();
}
if (null === $driver && !$stmt->rowCount()) {
if (null === $driver && !($result instanceof Result ? $result : $stmt)->rowCount()) {
try {
$insertStmt->execute();
} catch (DBALException $e) {

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\Lock\Store;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\InvalidTtlException;
@ -158,10 +159,10 @@ class PdoStore implements PersistingStoreInterface
$stmt->bindValue(':id', $this->getHashedKey($key));
$stmt->bindValue(':token1', $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 (!$stmt->rowCount() && !$this->exists($key)) {
if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this->exists($key)) {
throw new LockConflictedException();
}
@ -191,9 +192,9 @@ class PdoStore implements PersistingStoreInterface
$stmt->bindValue(':id', $this->getHashedKey($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());
}
/**

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
@ -144,7 +143,7 @@ class ConnectionTest extends TestCase
return $queryBuilder;
}
private function getStatementMock($expectedResult): ResultStatement
private function getStatementMock($expectedResult)
{
$stmt = $this->createMock(Statement::class);

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\Messenger\Bridge\Doctrine\Transport;
use Doctrine\DBAL\Connection as DBALConnection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Schema\Schema;
@ -350,7 +349,7 @@ class Connection implements ResetInterface
->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 {
$stmt = $this->driverConnection->executeQuery($sql, $parameters, $types);