Skip to content

Commit 3d1ed2e

Browse files
[Cache] fix DBAL v3 compat
1 parent 9a774ed commit 3d1ed2e

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Traits;
1313

14-
use Doctrine\DBAL\Driver\Result;
15-
1614
trait PdoPruneableTrait
1715
{
1816
protected function isPruned($cache, $name)
@@ -31,6 +29,6 @@ protected function isPruned($cache, $name)
3129
$select->bindValue(':id', sprintf('%%%s', $name));
3230
$result = $select->execute();
3331

34-
return 1 !== (int) ($result instanceof Result ? $result->fetchOne() : $select->fetch(\PDO::FETCH_COLUMN));
32+
return 1 !== (int) (\is_object($result) ? $result->fetchOne() : $select->fetch(\PDO::FETCH_COLUMN));
3533
}
3634
}

src/Symfony/Component/Cache/Traits/PdoTrait.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
namespace Symfony\Component\Cache\Traits;
1313

14-
use Doctrine\DBAL\Abstraction\Result;
1514
use Doctrine\DBAL\Connection;
1615
use Doctrine\DBAL\DBALException;
17-
use Doctrine\DBAL\Driver\Result as DriverResult;
1816
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
1917
use Doctrine\DBAL\Schema\Schema;
2018
use Symfony\Component\Cache\Exception\InvalidArgumentException;
@@ -187,7 +185,7 @@ protected function doFetch(array $ids)
187185
}
188186
$result = $stmt->execute();
189187

190-
if ($result instanceof Result) {
188+
if (\is_object($result)) {
191189
$result = $result->iterateNumeric();
192190
} else {
193191
$stmt->setFetchMode(\PDO::FETCH_NUM);
@@ -226,7 +224,7 @@ protected function doHave($id)
226224
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
227225
$result = $stmt->execute();
228226

229-
return (bool) ($result instanceof DriverResult ? $result->fetchOne() : $stmt->fetchColumn());
227+
return (bool) (\is_object($result) ? $result->fetchOne() : $stmt->fetchColumn());
230228
}
231229

232230
/**
@@ -352,7 +350,7 @@ protected function doSave(array $values, $lifetime)
352350
foreach ($serialized as $id => $data) {
353351
$result = $stmt->execute();
354352

355-
if (null === $driver && !($result instanceof DriverResult ? $result->rowCount() : $stmt->rowCount())) {
353+
if (null === $driver && !(\is_object($result) ? $result->rowCount() : $stmt->rowCount())) {
356354
try {
357355
$insertStmt->execute();
358356
} catch (DBALException $e) {

0 commit comments

Comments
 (0)