[Cache] fix DBAL v3 compat

This commit is contained in:
Nicolas Grekas 2020-09-27 14:33:10 +02:00
parent 9a774ede48
commit 3d1ed2e90d
2 changed files with 4 additions and 8 deletions

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Cache\Tests\Traits; namespace Symfony\Component\Cache\Tests\Traits;
use Doctrine\DBAL\Driver\Result;
trait PdoPruneableTrait trait PdoPruneableTrait
{ {
protected function isPruned($cache, $name) protected function isPruned($cache, $name)
@ -31,6 +29,6 @@ trait PdoPruneableTrait
$select->bindValue(':id', sprintf('%%%s', $name)); $select->bindValue(':id', sprintf('%%%s', $name));
$result = $select->execute(); $result = $select->execute();
return 1 !== (int) ($result instanceof Result ? $result->fetchOne() : $select->fetch(\PDO::FETCH_COLUMN)); return 1 !== (int) (\is_object($result) ? $result->fetchOne() : $select->fetch(\PDO::FETCH_COLUMN));
} }
} }

View File

@ -11,10 +11,8 @@
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\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\Exception\InvalidArgumentException;
@ -187,7 +185,7 @@ trait PdoTrait
} }
$result = $stmt->execute(); $result = $stmt->execute();
if ($result instanceof Result) { if (\is_object($result)) {
$result = $result->iterateNumeric(); $result = $result->iterateNumeric();
} else { } else {
$stmt->setFetchMode(\PDO::FETCH_NUM); $stmt->setFetchMode(\PDO::FETCH_NUM);
@ -226,7 +224,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 DriverResult ? $result->fetchOne() : $stmt->fetchColumn()); return (bool) (\is_object($result) ? $result->fetchOne() : $stmt->fetchColumn());
} }
/** /**
@ -352,7 +350,7 @@ trait PdoTrait
foreach ($serialized as $id => $data) { foreach ($serialized as $id => $data) {
$result = $stmt->execute(); $result = $stmt->execute();
if (null === $driver && !($result instanceof DriverResult ? $result->rowCount() : $stmt->rowCount())) { if (null === $driver && !(\is_object($result) ? $result->rowCount() : $stmt->rowCount())) {
try { try {
$insertStmt->execute(); $insertStmt->execute();
} catch (DBALException $e) { } catch (DBALException $e) {