Skip to content

Commit

Permalink
避免时间戳相加整型溢出
Browse files Browse the repository at this point in the history
  • Loading branch information
hongweipeng authored and liu21st committed Oct 14, 2019
1 parent abaec03 commit 63f1d0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/think/cache/driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function getRaw(string $name)

if (false !== $content) {
$expire = (int) substr($content, 8, 12);
if (0 != $expire && time() > filemtime($filename) + $expire) {
if (0 != $expire && time() - $expire > filemtime($filename)) {
//缓存过期删除缓存文件
$this->unlink($filename);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/think/session/driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function gc(): void
$now = time();

$files = $this->findFiles($this->config['path'], function (SplFileInfo $item) use ($lifetime, $now) {
return $now > $item->getMTime() + $lifetime;
return $now - $lifetime > $item->getMTime();
});

foreach ($files as $file) {
Expand Down

0 comments on commit 63f1d0b

Please sign in to comment.