Merge branch '3.4' into 4.4

* 3.4:
  Correctly use doctrine/dbal v3+
This commit is contained in:
Nicolas Grekas 2020-06-09 16:07:49 +02:00
commit 2ebb63a883
3 changed files with 7 additions and 5 deletions

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\Doctrine\Security\RememberMe; namespace Symfony\Bridge\Doctrine\Security\RememberMe;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken; use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
@ -63,7 +64,7 @@ class DoctrineTokenProvider implements TokenProviderInterface
$paramValues = ['series' => $series]; $paramValues = ['series' => $series];
$paramTypes = ['series' => \PDO::PARAM_STR]; $paramTypes = ['series' => \PDO::PARAM_STR];
$stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes); $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) { if ($row) {
return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['last_used'])); return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['last_used']));

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Cache\Tests\Traits; namespace Symfony\Component\Cache\Tests\Traits;
use Doctrine\DBAL\Result; use Doctrine\DBAL\Driver\Result;
trait PdoPruneableTrait trait PdoPruneableTrait
{ {

View File

@ -11,12 +11,13 @@
namespace Symfony\Component\Cache\Traits; namespace Symfony\Component\Cache\Traits;
use Doctrine\DBAL\Abstraction\Result;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception\TableNotFoundException; use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Exception\InvalidArgumentException;
use Symfony\Component\Cache\Marshaller\DefaultMarshaller; use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
@ -234,7 +235,7 @@ trait PdoTrait
$stmt->bindValue(':time', time(), \PDO::PARAM_INT); $stmt->bindValue(':time', time(), \PDO::PARAM_INT);
$result = $stmt->execute(); $result = $stmt->execute();
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn()); return (bool) ($result instanceof DriverResult ? $result->fetchOne() : $stmt->fetchColumn());
} }
/** /**
@ -376,7 +377,7 @@ trait PdoTrait
} }
$result = $stmt->execute(); $result = $stmt->execute();
} }
if (null === $driver && !($result instanceof Result ? $result : $stmt)->rowCount()) { if (null === $driver && !($result instanceof DriverResult ? $result : $stmt)->rowCount()) {
try { try {
$insertStmt->execute(); $insertStmt->execute();
} catch (DBALException $e) { } catch (DBALException $e) {