Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After the last transition stored in tzdata (about 2037),
timezone_transitions_get()computes transitions one year at a time. The loop always started at the year of the last stored transition. Years before$timestampBeginwere computed and then discarded, so the cost depended on how far in the future the range was, not on its size.This call loops over about 292 billion years. That's hours of CPU, and it ends with "Maximum execution time exceeded". The bug has been present since PHP 8.1 (d9c8e5a, bug #80963).
The loop now starts at the year before the one containing
$timestampBegin, or at the old starting year if that is later. The extra year matches timelib's own lookup intimelib_fetch_posix_timezone_offset(), which computes years Y−1 to Y+1. It covers a late-December change from the previous year that falls just inside the range in UTC.The output is unchanged for every range: the years no longer computed only produced entries before
$timestampBegin, which the existing check discarded. With the default$timestampBegin(PHP_INT_MIN), the starting year stays as before.$end1e111e121e131e141e15PHP_INT_MAX