framework icon indicating copy to clipboard operation
framework copied to clipboard

FileStore: issue with deserialization when changing Date::now()

Open murrant opened this issue 5 months ago • 2 comments

Laravel Version

12.19.2

PHP Version

8.4.8

Database Driver & Version

No response

Description

When using the FileStore cache driver, if you store something in the cache with expiration while time traveling, it will break deserialization. This is because FileStore assumes a timestamp is 10 digits.

Steps To Reproduce

    public function test_write_and_fetch_file_cache_with_old_timestamp(): void
    {
        Date::withTestNow(Date::createFromTimestampUTC(990464400), function () {
            Cache::driver('file')->put('key', 'value', 3);
            $this->assertEquals('value', Cache::driver('file')->get('key'));
        });

        $this->assertEquals('value', Cache::driver('file')->get('key'));
    }

murrant avatar Jun 18 '25 05:06 murrant