Skip to content

Commit 64f312f

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix phpGH-16454: Unhandled INF in date_sunset() with tiny $utcOffset
2 parents c26d5f2 + 9bc3418 commit 64f312f

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ PHP NEWS
1818
. Fixed bug GH-16302 (CurlMultiHandle holds a reference to CurlHandle if
1919
curl_multi_add_handle fails). (timwolla)
2020

21+
- Date:
22+
. Fixed bug GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset).
23+
(cmb)
24+
2125
- DOM:
2226
. Fixed bug GH-16316 (DOMXPath breaks when not initialized properly).
2327
(nielsdos)

ext/date/php_date.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5328,6 +5328,9 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
53285328
if (N > 24 || N < 0) {
53295329
N -= floor(N / 24) * 24;
53305330
}
5331+
if (N > 24 || N < 0) {
5332+
RETURN_FALSE;
5333+
}
53315334

53325335
switch (retformat) {
53335336
case SUNFUNCS_RET_STRING:

ext/date/tests/gh16454.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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: Function date_sunrise() is deprecated in %s on line %d
12+
bool(false)
13+
14+
Deprecated: Function date_sunrise() is deprecated in %s on line %d
15+
bool(false)
16+
17+
Deprecated: Function date_sunset() is deprecated in %s on line %d
18+
bool(false)
19+
20+
Deprecated: Function date_sunset() is deprecated in %s on line %d
21+
bool(false)

0 commit comments

Comments
 (0)