Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e564c70

Browse files
bug #27576 [Cache] Fix expiry comparisons in array-based pools (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Cache] Fix expiry comparisons in array-based pools | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 68729cc [Cache] Fix expiry comparisons in array-based pools
2 parents 24b6848 + 68729cc commit e564c70

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function doContains($id)
2121

2222
$expiry = $this->data[$id][1];
2323

24-
return !$expiry || time() <= $expiry || !$this->doDelete($id);
24+
return !$expiry || time() < $expiry || !$this->doDelete($id);
2525
}
2626

2727
protected function doSave($id, $data, $lifeTime = 0)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function hasItem($key)
4444
{
4545
CacheItem::validateKey($key);
4646

47-
return isset($this->expiries[$key]) && ($this->expiries[$key] >= time() || !$this->deleteItem($key));
47+
return isset($this->expiries[$key]) && ($this->expiries[$key] > time() || !$this->deleteItem($key));
4848
}
4949

5050
/**
@@ -81,7 +81,7 @@ private function generateItems(array $keys, $now, $f)
8181
{
8282
foreach ($keys as $i => $key) {
8383
try {
84-
if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] >= $now || !$this->deleteItem($key))) {
84+
if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) {
8585
$this->values[$key] = $value = null;
8686
} elseif (!$this->storeSerialized) {
8787
$value = $this->values[$key];

0 commit comments

Comments
 (0)