Merge branch '4.4' into 5.0
* 4.4: Correctly use doctrine/dbal v3+ Correctly use doctrine/dbal v3+
This commit is contained in:
commit
9bfe5065b7
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\Doctrine\Security\RememberMe;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
|
||||
@ -63,7 +64,7 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
||||
$paramValues = ['series' => $series];
|
||||
$paramTypes = ['series' => \PDO::PARAM_STR];
|
||||
$stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes);
|
||||
$row = method_exists($stmt, 'fetchAssociative') ? $stmt->fetchAssociative() : $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$row = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['last_used']));
|
||||
|
@ -11,12 +11,13 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Adapter;
|
||||
|
||||
use Doctrine\DBAL\Abstraction\Result;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result as DriverResult;
|
||||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Result;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
|
||||
@ -258,7 +259,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
|
||||
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||
$result = $stmt->execute();
|
||||
|
||||
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn());
|
||||
return (bool) ($result instanceof DriverResult ? $result->fetchOne() : $stmt->fetchColumn());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,7 +401,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
|
||||
}
|
||||
$result = $stmt->execute();
|
||||
}
|
||||
if (null === $driver && !($result instanceof Result ? $result : $stmt)->rowCount()) {
|
||||
if (null === $driver && !($result instanceof DriverResult ? $result : $stmt)->rowCount()) {
|
||||
try {
|
||||
$insertStmt->execute();
|
||||
} catch (DBALException $e) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Traits;
|
||||
|
||||
use Doctrine\DBAL\Result;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
|
||||
trait PdoPruneableTrait
|
||||
{
|
||||
|
@ -13,8 +13,8 @@ namespace Symfony\Component\Lock\Store;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
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;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Messenger\Tests\Transport\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Doctrine\DBAL\Schema\AbstractSchemaManager;
|
||||
@ -29,7 +30,7 @@ class ConnectionTest extends TestCase
|
||||
$queryBuilder = $this->getQueryBuilderMock();
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
$schemaSynchronizer = $this->getSchemaSynchronizerMock();
|
||||
$stmt = $this->getStatementMock([
|
||||
$stmt = $this->getResultMock([
|
||||
'id' => 1,
|
||||
'body' => '{"message":"Hi"}',
|
||||
'headers' => json_encode(['type' => DummyMessage::class]),
|
||||
@ -63,7 +64,7 @@ class ConnectionTest extends TestCase
|
||||
$queryBuilder = $this->getQueryBuilderMock();
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
$schemaSynchronizer = $this->getSchemaSynchronizerMock();
|
||||
$stmt = $this->getStatementMock(false);
|
||||
$stmt = $this->getResultMock(false);
|
||||
|
||||
$queryBuilder
|
||||
->method('getParameters')
|
||||
@ -142,12 +143,12 @@ class ConnectionTest extends TestCase
|
||||
return $queryBuilder;
|
||||
}
|
||||
|
||||
private function getStatementMock($expectedResult)
|
||||
private function getResultMock($expectedResult)
|
||||
{
|
||||
$stmt = $this->createMock(Statement::class);
|
||||
$stmt = $this->createMock(interface_exists(Result::class) ? Result::class : Statement::class);
|
||||
|
||||
$stmt->expects($this->once())
|
||||
->method(method_exists(Statement::class, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
|
||||
->method(interface_exists(Result::class) ? 'fetchAssociative' : 'fetch')
|
||||
->willReturn($expectedResult);
|
||||
|
||||
return $stmt;
|
||||
@ -262,7 +263,7 @@ class ConnectionTest extends TestCase
|
||||
$driverConnection = $this->getDBALConnectionMock();
|
||||
$schemaSynchronizer = $this->getSchemaSynchronizerMock();
|
||||
$id = 1;
|
||||
$stmt = $this->getStatementMock([
|
||||
$stmt = $this->getResultMock([
|
||||
'id' => $id,
|
||||
'body' => '{"message":"Hi"}',
|
||||
'headers' => json_encode(['type' => DummyMessage::class]),
|
||||
@ -307,9 +308,9 @@ class ConnectionTest extends TestCase
|
||||
'headers' => json_encode(['type' => DummyMessage::class]),
|
||||
];
|
||||
|
||||
$stmt = $this->createMock(Statement::class);
|
||||
$stmt = $this->createMock(interface_exists(Result::class) ? Result::class : Statement::class);
|
||||
$stmt->expects($this->once())
|
||||
->method(method_exists(Statement::class, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
|
||||
->method(interface_exists(Result::class) ? 'fetchAllAssociative' : 'fetchAll')
|
||||
->willReturn([$message1, $message2]);
|
||||
|
||||
$driverConnection
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Messenger\Tests\Transport\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Version;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -71,7 +72,7 @@ class DoctrineIntegrationTest extends TestCase
|
||||
->setParameter(':body', '{"message": "Hi i am delayed"}')
|
||||
->execute();
|
||||
|
||||
$available_at = new \DateTime(method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn());
|
||||
$available_at = new \DateTime($stmt instanceof Result ? $stmt->fetchOne() : $stmt->fetchColumn());
|
||||
|
||||
$now = new \DateTime();
|
||||
$now->modify('+60 seconds');
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Messenger\Transport\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\Connection as DBALConnection;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
@ -163,7 +164,7 @@ class Connection
|
||||
$query->getParameters(),
|
||||
$query->getParameterTypes()
|
||||
);
|
||||
$doctrineEnvelope = method_exists($stmt, 'fetchAssociative') ? $stmt->fetchAssociative() : $stmt->fetch();
|
||||
$doctrineEnvelope = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch();
|
||||
|
||||
if (false === $doctrineEnvelope) {
|
||||
$this->driverConnection->commit();
|
||||
@ -251,7 +252,7 @@ class Connection
|
||||
|
||||
$stmt = $this->executeQuery($queryBuilder->getSQL(), $queryBuilder->getParameters(), $queryBuilder->getParameterTypes());
|
||||
|
||||
return method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn();
|
||||
return $stmt instanceof Result ? $stmt->fetchOne() : $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
public function findAll(int $limit = null): array
|
||||
@ -262,7 +263,7 @@ class Connection
|
||||
}
|
||||
|
||||
$stmt = $this->executeQuery($queryBuilder->getSQL(), $queryBuilder->getParameters(), $queryBuilder->getParameterTypes());
|
||||
$data = method_exists($stmt, 'fetchAllAssociative') ? $stmt->fetchAllAssociative() : $stmt->fetchAll();
|
||||
$data = $stmt instanceof Result ? $stmt->fetchAllAssociative() : $stmt->fetchAll();
|
||||
|
||||
return array_map(function ($doctrineEnvelope) {
|
||||
return $this->decodeEnvelopeHeaders($doctrineEnvelope);
|
||||
@ -275,7 +276,7 @@ class Connection
|
||||
->where('m.id = ?');
|
||||
|
||||
$stmt = $this->executeQuery($queryBuilder->getSQL(), [$id]);
|
||||
$data = method_exists($stmt, 'fetchAssociative') ? $stmt->fetchAssociative() : $stmt->fetch();
|
||||
$data = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch();
|
||||
|
||||
return false === $data ? null : $this->decodeEnvelopeHeaders($data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user