Skip to content

Commit 1337dbf

Browse files
Merge branch '4.2' into 4.3
* 4.2: [Lock] fix bad merge
2 parents 953ac3e + 432c21f commit 1337dbf

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\DBAL\Schema\Schema;
1717
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
19-
use Symfony\Component\Lock\Exception\LockExpiredException;
2019
use Symfony\Component\Lock\Exception\NotSupportedException;
2120
use Symfony\Component\Lock\Key;
2221
use Symfony\Component\Lock\StoreInterface;
@@ -36,6 +35,8 @@
3635
*/
3736
class PdoStore implements StoreInterface
3837
{
38+
use ExpiringStoreTrait;
39+
3940
private $conn;
4041
private $dsn;
4142
private $driver;
@@ -123,9 +124,7 @@ public function save(Key $key)
123124

124125
try {
125126
$stmt->execute();
126-
if ($key->isExpired()) {
127-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
128-
}
127+
$this->checkNotExpired($key);
129128

130129
return;
131130
} catch (DBALException $e) {
@@ -136,9 +135,7 @@ public function save(Key $key)
136135
$this->putOffExpiration($key, $this->initialTtl);
137136
}
138137

139-
if ($key->isExpired()) {
140-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
141-
}
138+
$this->checkNotExpired($key);
142139

143140
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
144141
$this->prune();
@@ -178,9 +175,7 @@ public function putOffExpiration(Key $key, $ttl)
178175
throw new LockConflictedException();
179176
}
180177

181-
if ($key->isExpired()) {
182-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
183-
}
178+
$this->checkNotExpired($key);
184179
}
185180

186181
/**

0 commit comments

Comments
 (0)