-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GH-18481: date_sunrise check sun rise with offset if is finite/is… #18484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ext/date/php_date.c
Outdated
@@ -5346,7 +5346,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s | |||
if (N > 24 || N < 0) { | |||
N -= floor(N / 24) * 24; | |||
} | |||
if (N > 24 || N < 0) { | |||
if (N > 24 || N < 0 || !zend_finite(N)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also possible to do it like this: if (!(N <= 24 && N >= 0)) {
, but yours works too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I m gonna try your simpler approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you copied the condition incorrectly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes..
ext/date/tests/gh18481.phpt
Outdated
@@ -0,0 +1,21 @@ | |||
--TEST-- | |||
GH-18481 date_sunrise with utcOffset as INF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GH-18481 date_sunrise with utcOffset as INF | |
GH-18481 (date_sunrise with utcOffset as INF) |
… nan