|
14 | 14 | use Doctrine\DBAL\Connection; |
15 | 15 | use Doctrine\DBAL\DBALException; |
16 | 16 | use Doctrine\DBAL\DriverManager; |
| 17 | +use Doctrine\DBAL\Result; |
17 | 18 | use Doctrine\DBAL\Schema\Schema; |
18 | 19 | use Symfony\Component\Lock\Exception\InvalidArgumentException; |
19 | 20 | use Symfony\Component\Lock\Exception\InvalidTtlException; |
@@ -168,10 +169,10 @@ public function putOffExpiration(Key $key, $ttl) |
168 | 169 | $stmt->bindValue(':id', $this->getHashedKey($key)); |
169 | 170 | $stmt->bindValue(':token1', $uniqueToken); |
170 | 171 | $stmt->bindValue(':token2', $uniqueToken); |
171 | | - $stmt->execute(); |
| 172 | + $result = $stmt->execute(); |
172 | 173 |
|
173 | 174 | // 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)) { |
175 | 176 | throw new LockConflictedException(); |
176 | 177 | } |
177 | 178 |
|
@@ -201,9 +202,9 @@ public function exists(Key $key) |
201 | 202 |
|
202 | 203 | $stmt->bindValue(':id', $this->getHashedKey($key)); |
203 | 204 | $stmt->bindValue(':token', $this->getUniqueToken($key)); |
204 | | - $stmt->execute(); |
| 205 | + $result = $stmt->execute(); |
205 | 206 |
|
206 | | - return (bool) (method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn()); |
| 207 | + return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn()); |
207 | 208 | } |
208 | 209 |
|
209 | 210 | /** |
|
0 commit comments