8000 bug #45029 [Cache] Set mtime of cache files 1 year into future if the… · symfony/cache@0c855e2 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 0c855e2

Browse files
bug #45029 [Cache] Set mtime of cache files 1 year into future if they do not expire (Blacksmoke16)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Cache] Set mtime of cache files 1 year into future if they do not expire | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? |no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - symfony/symfony#26127 made is so that `0` is used to represent cache files that do not expire. However this was causing `touch` to be called with `0`, which was setting the create/modification time of the file to start of epoch time, which doesn't really make sense. It can cause some issues with `tar` for example as when timezones are taken into consideration you end up with warnings like: > tar: app/cache/prod/annotations/@/+/3/cdcAWwqaPORAi0TfsO5Q: implausibly old time stamp 1969-12-31 19:00:00 Given the expiration of the files is stored within the file itself, it's probably safe to not `touch` it if that value is `0`. However is there actually a reason to touch it at all as a file that expires in 6 hours would show as created 6 hours into the future. I also wasn't sure how to test this, so open to suggestions on that/if we need the `touch` at all. Commits ------- 57cad6f9a4 [Cache] Set mtime of cache files 1 year into future if they do not expire
2 parents a6a90c6 + a992828 commit 0c855e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Traits/FilesystemCommonTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function write(string $file, string $data, int $expiresAt = null)
109109
fclose($h);
110110

111111
if (null !== $expiresAt) {
112-
touch($this->tmp, $expiresAt);
112+
touch($this->tmp, $expiresAt ?: time() + 31556952); // 1 year in seconds
113113
}
114114

115115
return rename($this->tmp, $file);

0 commit comments

Comments
 (0)
0