Skip to content

Commit b7ccf10

Browse files
[Cache] Improve resiliency when calling doFetch() in AbstractTrait
1 parent bef15ce commit b7ccf10

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Symfony/Component/Cache/Traits/AbstractTrait.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ public function clear()
108108
try {
109109
if ($cleared = $this->versioningIsEnabled) {
110110
$namespaceVersion = 2;
111-
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
112-
$namespaceVersion = 1 + (int) $v;
111+
try {
112+
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
113+
$namespaceVersion = 1 + (int) $v;
114+
}
115+
} catch (\Exception $e) {
113116
}
114117
$namespaceVersion .= ':';
115118
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
@@ -236,8 +239,11 @@ private function getId($key)
236239

237240
if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
238241
$this->namespaceVersion = '1:';
239-
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
240-
$this->namespaceVersion = $v;
242+
try {
243+
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
244+
$this->namespaceVersion = $v;
245+
}
246+
} catch (\Exception $e) {
241247
}
242248
}
243249

0 commit comments

Comments
 (0)