diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index 8810eb06d72df..a7da0248c3833 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -171,9 +171,14 @@ public function exists(Key $key) $storesCount = \count($this->stores); foreach ($this->stores as $store) { - if ($store->exists($key)) { - ++$successCount; - } else { + try { + if ($store->exists($key)) { + ++$successCount; + } else { + ++$failureCount; + } + } catch (\Exception $e) { + $this->logger->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]); ++$failureCount; } diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index c8da617fae61d..98240e8193981 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -351,4 +351,29 @@ public function testDeleteDontStopOnFailure() $this->store->delete($key); } + + public function testExistsDontStopOnFailure() + { + $key = new Key(uniqid(__METHOD__, true)); + + $this->strategy + ->expects($this->any()) + ->method('canBeMet') + ->willReturn(true); + $this->strategy + ->expects($this->any()) + ->method('isMet') + ->willReturn(false); + $this->store1 + ->expects($this->once()) + ->method('exists') + ->willThrowException(new \Exception()); + $this->store2 + ->expects($this->once()) + ->method('exists') + ->with($key) + ->willReturn(false); + + $this->assertFalse($this->store->exists($key)); + } }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: