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

Skip to content

Commit 268816f

Browse files
phamvietnicolas-grekas
authored andcommitted
[Cache] Fixed expiry maybe int due too race conditions
1 parent 2fb61a4 commit 268816f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/Cache/Adapter/ChainAdapter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ static function ($sourceItem, $item, $sourceMetadata = null) use ($defaultLifeti
7474
$item->metadata = $item->newMetadata = $sourceItem->metadata = $sourceMetadata;
7575

7676
if (isset($item->metadata[CacheItem::METADATA_EXPIRY])) {
77-
$item->expiresAt(\DateTime::createFromFormat('U.u', $item->metadata[CacheItem::METADATA_EXPIRY]));
77+
if (\is_int($expiry = $item->metadata[CacheItem::METADATA_EXPIRY])) {
78+
$item->expiresAt(\DateTime::createFromFormat('U', $expiry));
79+
} else {
80+
$item->expiresAt(\DateTime::createFromFormat('U.u', sprintf('%.3F', $expiry)));
81+
}
7882
} elseif (0 < $defaultLifetime) {
7983
$item->expiresAfter($defaultLifetime);
8084
}

0 commit comments

Comments
 (0)