Skip to content

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