Fix DST caching bug by using strict timestamp arithmetic and add regression test - #215
Conversation
…ession test This ensures that during DST transitions (Summer -> Winter), relative date calculations (like -1 seconds) are absolute and not affected by timezone ambiguity. Fixes #194
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug where cache entries could be incorrectly marked as valid or stale for an extended period during Daylight Saving Time transitions. The fix involves a fundamental change in how cache expiration times are calculated, moving from potentially ambiguous date modifications to precise, absolute timestamp arithmetic. A dedicated regression test has been added to prevent future recurrences of this issue, ensuring robust caching behavior across time zone changes. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug related to Daylight Saving Time transitions by using UNIX timestamps for cache expiration calculations instead of relative date modifications. The changes in GreedyCacheStrategy.php and PrivateCacheStrategy.php are sound. The addition of the regression test testDstTransitionDoesNotIncorrectlyCache is excellent, as it specifically targets the fixed bug and ensures it doesn't reappear. My feedback includes a couple of suggestions to further improve test isolation and code maintainability.
Description
This PR resolves issue #194, where cache entries could be incorrectly cached for nearly an hour during the Daylight Saving Time (DST) transition (Summer -> Winter).
Changes
\DateTimeImmutable::modify()with direct timestamp manipulation (setTimestamp()) for relative dates. This avoids the ambiguity of local time during DST transitions, as UNIX timestamps are absolute.testDstTransitionDoesNotIncorrectlyCacheinPrivateCacheTest. It mocks the system time precisely during the transition point in theEurope/Berlintimezone to ensure the fix works as expected.Clockis reset to aNativeClockafter time-sensitive tests.Verification