Skip to content

Commit 7ce58f2

Browse files
Merge branch '5.1' into 5.2
* 5.1: Fix EncoderInterface::encode() return type [Lock] Prevent store exception break combined store Remove check for unsupported PHP version [Notifier] Rename test method names
2 parents 30232c7 + 0f5e0f4 commit 7ce58f2

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Store/CombinedStore.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,14 @@ public function exists(Key $key)
199199
$storesCount = \count($this->stores);
200200

201201
foreach ($this->stores as $store) {
202-
if ($store->exists($key)) {
203-
++$successCount;
204-
} else {
202+
try {
203+
if ($store->exists($key)) {
204+
++$successCount;
205+
} else {
206+
++$failureCount;
207+
}
208+
} catch (\Exception $e) {
209+
$this->logger->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
205210
++$failureCount;
206211
}
207212

Tests/Store/CombinedStoreTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,31 @@ public function testDeleteDontStopOnFailure()
354354
$this->store->delete($key);
355355
}
356356

357+
public function testExistsDontStopOnFailure()
358+
{
359+
$key = new Key(uniqid(__METHOD__, true));
360+
361+
$this->strategy
362+
->expects($this->any())
363+
->method('canBeMet')
364+
->willReturn(true);
365+
$this->strategy
366+
->expects($this->any())
367+
->method('isMet')
368+
->willReturn(false);
369+
$this->store1
370+
->expects($this->once())
371+
->method('exists')
372+
->willThrowException(new \Exception());
373+
$this->store2
374+
->expects($this->once())
375+
->method('exists')
376+
->with($key)
377+
->willReturn(false);
378+
379+
$this->assertFalse($this->store->exists($key));
380+
}
381+
357382
public function testSaveReadWithCompatibleStore()
358383
{
359384
$key = new Key(uniqid(__METHOD__, true));

0 commit comments

Comments
 (0)