Skip to content

Commit a920afd

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix phpGH-16454: Unhandled INF in date_sunset() with tiny $utcOffset
2 parents e61e2c1 + 66fe549 commit a920afd

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

ext/date/php_date.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5516,6 +5516,9 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
55165516
if (N > 24 || N < 0) {
55175517
N -= floor(N / 24) * 24;
55185518
}
5519+
if (N > 24 || N < 0) {
5520+
RETURN_FALSE;
5521+
}
55195522

55205523
switch (retformat) {
55215524
case SUNFUNCS_RET_STRING:

ext/date/tests/gh16454.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset)
3+
--FILE--
4+
<?php
5+
var_dump(date_sunrise(0, SUNFUNCS_RET_STRING, 61, -150, 90, PHP_FLOAT_MAX));
6+
var_dump(date_sunrise(0, SUNFUNCS_RET_STRING, 61, -150, 90, -PHP_FLOAT_MAX));
7+
var_dump(date_sunset(0, SUNFUNCS_RET_STRING, 61, -150, 90, PHP_FLOAT_MAX));
8+
var_dump(date_sunset(0, SUNFUNCS_RET_STRING, 61, -150, 90, -PHP_FLOAT_MAX));
9+
?>
10+
--EXPECTF--
11+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
12+
13+
Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
14+
bool(false)
15+
16+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
17+
18+
Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
19+
bool(false)
20+
21+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
22+
23+
Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
24+
bool(false)
25+
26+
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d
27+
28+
Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
29+
bool(false)

0 commit comments

Comments
 (0)