[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;
use Doctrine\DBAL\Driver\Result;
trait PdoPruneableTrait
{
protected function isPruned($cache, $name)
@ -31,6 +29,6 @@ trait PdoPruneableTrait
$select->bindValue(':id', sprintf('%%%s', $name));
$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;
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\Schema\Schema;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
@ -187,7 +185,7 @@ trait PdoTrait
}
$result = $stmt->execute();
if ($result instanceof Result) {
if (\is_object($result)) {
$result = $result->iterateNumeric();
} else {
$stmt->setFetchMode(\PDO::FETCH_NUM);
@ -226,7 +224,7 @@ trait PdoTrait
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
$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) {
$result = $stmt->execute();
if (null === $driver && !($result instanceof DriverResult ? $result->rowCount() : $stmt->rowCount())) {
if (null === $driver && !(\is_object($result) ? $result->rowCount() : $stmt->rowCount())) {
try {
$insertStmt->execute();
} catch (DBALException $e) {