Skip to content

Commit cac1205

Browse files
[Lock] fix compat with doctrine/dbal v3
1 parent 55b1ae7 commit cac1205

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;
@@ -168,10 +169,10 @@ public function putOffExpiration(Key $key, $ttl)
168169
$stmt->bindValue(':id', $this->getHashedKey($key));
169170
$stmt->bindValue(':token1', $uniqueToken);
170171
$stmt->bindValue(':token2', $uniqueToken);
171-
$stmt->execute();
172+
$result = $stmt->execute();
172173

173174
// 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
174-
if (!$stmt->rowCount() && !$this->exists($key)) {
175+
if (!($result instanceof Result ? $result : $stmt)->rowCount() && !$this->exists($key)) {
175176
throw new LockConflictedException();
176177
}
177178

@@ -201,9 +202,9 @@ public function exists(Key $key)
201202

202203
$stmt->bindValue(':id', $this->getHashedKey($key));
203204
$stmt->bindValue(':token', $this->getUniqueToken($key));
204-
$stmt->execute();
205+
$result = $stmt->execute();
205206

206-
return (bool) (method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn());
207+
return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn());
207208
}
208209

209210
/**

0 commit comments

Comments
 (0)