|
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;
|
@@ -158,10 +159,10 @@ public function putOffExpiration(Key $key, float $ttl)
|
158 | 159 | $stmt->bindValue(':id', $this->getHashedKey($key));
|
159 | 160 | $stmt->bindValue(':token1', $uniqueToken);
|
160 | 161 | $stmt->bindValue(':token2', $uniqueToken);
|
161 |
| - $stmt->execute(); |
| 162 | + $result = $stmt->execute(); |
162 | 163 |
|
163 | 164 | // 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)) { |
165 | 166 | throw new LockConflictedException();
|
166 | 167 | }
|
167 | 168 |
|
@@ -191,9 +192,9 @@ public function exists(Key $key)
|
191 | 192 |
|
192 | 193 | $stmt->bindValue(':id', $this->getHashedKey($key));
|
193 | 194 | $stmt->bindValue(':token', $this->getUniqueToken($key));
|
194 |
| - $stmt->execute(); |
| 195 | + $result = $stmt->execute(); |
195 | 196 |
|
196 |
| - return (bool) (method_exists($stmt, 'fetchOne') ? $stmt->fetchOne() : $stmt->fetchColumn()); |
| 197 | + return (bool) ($result instanceof Result ? $result->fetchOne() : $stmt->fetchColumn()); |
197 | 198 | }
|
198 | 199 |
|
199 | 200 | /**
|
|
0 commit comments