[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Weilin Du | Date: | Mon, 23 Nov 2026 16:45:08 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144069@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-11-24T00:31:27+08:00
Commit: https://github.com/php/php-src/commit/3502e6f32521f5e0cf737021441d581f6556cc93
Raw diff: https://github.com/php/php-src/commit/3502e6f32521f5e0cf737021441d581f6556cc93.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/intl: Reject non-finite timestamps in IntlCalendar::setTime() (#25668)
Changed paths:
A ext/intl/tests/calendar_setTime_non_finite.phpt
M NEWS
M ext/intl/calendar/calendar_methods.cpp
Diff:
diff --git a/NEWS b/NEWS
index 5bddd9a26994..c16bf3f80489 100644
--- a/NEWS
+++ b/NEWS
@@ -72,6 +72,7 @@ PHP NEWS
- Intl:
. Fixed Locale::lookup() ignoring the default locale when the language tag
list is empty. (Weilin Du)
+ . Fixed IntlCalendar::setTime() accepting non-finite timestamps. (Weilin Du)
- JSON:
. Fixed json_decode() and json_validate() error messages. (lacatoire)
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
index 18347dce4be3..630563cbfcf8 100644
--- a/ext/intl/calendar/calendar_methods.cpp
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -268,6 +268,12 @@ U_CFUNC PHP_FUNCTION(intlcal_set_time)
CALENDAR_METHOD_FETCH_OBJECT;
+ if (UNEXPECTED(!zend_finite(time_arg))) {
+ intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
+ "Timestamp must be finite", 0);
+ RETURN_FALSE;
+ }
+
co->ucal->setTime((UDate)time_arg, CALENDAR_ERROR_CODE(co));
INTL_METHOD_CHECK_STATUS(co, "Call to underlying method failed");
diff --git a/ext/intl/tests/calendar_setTime_non_finite.phpt
b/ext/intl/tests/calendar_setTime_non_finite.phpt
new file mode 100644
index 000000000000..0d7515268754
--- /dev/null
+++ b/ext/intl/tests/calendar_setTime_non_finite.phpt
@@ -0,0 +1,28 @@
+--TEST--
+IntlCalendar::setTime() rejects non-finite timestamps
+--CREDITS--
+Wong Wai Kin
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+$calendar = IntlCalendar::createInstance('UTC');
+var_dump($calendar->setTime(1234));
+
+foreach ([NAN, INF, -INF] as $timestamp) {
+ var_dump($calendar->setTime($timestamp));
+ var_dump($calendar->getErrorCode() === U_ILLEGAL_ARGUMENT_ERROR);
+ var_dump($calendar->getTime());
+}
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+float(1234)
+bool(false)
+bool(true)
+float(1234)
+bool(false)
+bool(true)
+float(1234)