Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf33635

Browse filesBrowse files
[Cache] prevent getting older entries when the version key is evicted
1 parent 9bc774c commit bf33635
Copy full SHA for bf33635

File tree

Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-8
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/AbstractTrait.php
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,7 @@ public function clear()
106106
{
107107
$this->deferred = array();
108108
if ($cleared = $this->versioningIsEnabled) {
109-
$namespaceVersion = 2;
110-
try {
111-
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
112-
$namespaceVersion = 1 + (int) $v;
113-
}
114-
} catch (\Exception $e) {
115-
}
116-
$namespaceVersion .= ':';
109+
$namespaceVersion = substr_replace(base64_encode(pack('V', time() - 1537685133 + mt_rand(0, 65535))), ':', 5);
117110
try {
118111
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
119112
} catch (\Exception $e) {
@@ -247,6 +240,10 @@ private function getId($key)
247240
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
248241
$this->namespaceVersion = $v;
249242
}
243+
if ('1:' === $this->namespaceVersion) {
244+
$this->namespaceVersion = substr_replace(base64_encode(pack('V', time() - 1537685133)), ':', 5);
245+
$this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0);
246+
}
250247
} catch (\Exception $e) {
251248
}
252249
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.