Skip to content

Commit a55de9e

Browse files
Merge branch '4.4' into 5.0
* 4.4: [Cache] fix compat with doctrine/dbal v3 [Lock] fix compat with doctrine/dbal v3
2 parents 712ed87 + cac1205 commit a55de9e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Store/PdoStore.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Connection;
1515
use Doctrine\DBAL\DBALException;
1616
use Doctrine\DBAL\DriverManager;
17+
use Doctrine\DBAL\Result;
1718
use Doctrine\DBAL\Schema\Schema;
1819
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1920
use Symfony\Component\Lock\Exception\InvalidTtlException;
@@ -158,10 +159,10 @@ public function putOffExpiration(Key $key, float $ttl)
158159
$stmt->bindValue(':id', $this->getHashedKey($key));
159160
$stmt->bindValue(':token1', $uniqueToken);
160161
$stmt->bindValue(':token2', $uniqueToken);
161-
$stmt->execute();
162+
$result = $stmt->execute();
162163

163164
// If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner
164-
if (!$stmt->rowCount() && !$this->exists($key)) {
165+
if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this->exists($key)) {
165166
throw new LockConflictedException();
166167
}
167168

@@ -191,9 +192,9 @@ public function exists(Key $key)
191192

192193
$stmt->bindValue(':id', $this->getHashedKey($key));
193194
$stmt->bindValue(':token', $this->getUniqueToken($key));
194-
$stmt->execute();
195+
$result = $stmt->execute();
195196

196-
return (bool) (method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn());
197+
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn());
197198
}
198199

199200
/**

0 commit comments

Comments
 (0)