Skip to content

Fix GH-14732: date_sun_info() fails for non-finite values #16497

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

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 18, 2024

timelib_astro_rise_set_altitude() is not prepared to deal with non- finite values (nan, inf and -inf) for lon and lat; instead these trigger undefined behavior. Thus we catch non-finite values before even calling that timelib function; for date_sun_info() we trigger ValueErrors; for date_sunrise() and date_sunset() we silently return false, since these functions will be sunsetted anyway.


Note for merger:

Test expectations for PHP 8.4 and up
date_sun_info(): Argument #2 ($latitude) must be finite
date_sun_info(): Argument #2 ($latitude) must be finite
date_sun_info(): Argument #3 ($longitude) must be finite
date_sun_info(): Argument #3 ($longitude) must be finite

Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d

Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
bool(false)

Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d

Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
bool(false)

`timelib_astro_rise_set_altitude()` is not prepared to deal with non-
finite values (`nan`, `inf` and `-inf`) for `lon` and `lat`; instead
these trigger undefined behavior.  Thus we catch non-finite values
before even calling that timelib function; for `date_sun_info()` we
trigger `ValueError`s; for `date_sunrise()` and `date_sunset()` we
silently return `false`, since these functions will be sunsetted
anyway.
@cmb69 cmb69 requested a review from derickr as a code owner October 18, 2024 16:01
@cmb69 cmb69 linked an issue Oct 18, 2024 that may be closed by this pull request
@cmb69
Copy link
Member Author

cmb69 commented Oct 25, 2024

If there are no objections, I'll merge this in a week.

@cmb69 cmb69 closed this in f9453a8 Nov 1, 2024
@cmb69 cmb69 deleted the cmb/gh14732 branch November 1, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

date_sun_info() fails for non-finite values
1 participant