1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-18481: date_sunrise check sun rise with offset if is finite/is nan

close GH-18484
This commit is contained in:
David Carlier
2025-05-02 07:24:15 +01:00
parent 24ab0f1ea1
commit 0227d96f48
3 changed files with 24 additions and 1 deletions

2
NEWS
View File

@@ -11,6 +11,8 @@ PHP NEWS
. Fixed bug GH-18076 (Since PHP 8, the date_sun_info() function returns
inaccurate sunrise and sunset times, but other calculated times are
correct) (JiriJozif).
. Fixed bug GH-18481 (date_sunrise with unexpected nan value for the offset).
(nielsdos/David Carlier)
- Intl:
. Fix various reference issues. (nielsdos)

View File

@@ -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)) {
RETURN_FALSE;
}

View File

@@ -0,0 +1,21 @@
--TEST--
GH-18481 (date_sunrise with utcOffset as INF)
--FILE--
<?php
foreach ([-NAN, NAN, INF, -INF] as $offset) {
var_dump(date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, $offset));
}
?>
--EXPECTF--
Deprecated: Function date_sunrise() is deprecated in %s on line %d
bool(false)
Deprecated: Function date_sunrise() is deprecated in %s on line %d
bool(false)
Deprecated: Function date_sunrise() is deprecated in %s on line %d
bool(false)
Deprecated: Function date_sunrise() is deprecated in %s on line %d
bool(false)