Commit f11c1facb44 for php.net
commit f11c1facb446f19ff41d9850bc986c0c290f0ef8
Author: ndossche <7771979+ndossche@users.noreply.github.com>
Date: Sun Jun 7 23:06:20 2026 +0200
date: Fix typo in condition in date_period_init_iso8601_string()
Now the address is being checked instead of the value, but I believe the
value should be checked against 0, not the pointer against NULL.
Closes GH-22253.
diff --git a/NEWS b/NEWS
index 2698420c7a5..7aa9ec33744 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed issues with oversized allocations and signed overflow in bcround()
and BcMath\Number::round(). (edorian)
+- Date:
+ . Fix incorrect recurrence check of DatePeriod::createFromISO8601String().
+ (ndossche)
+
- GD:
. Fixed bug GH-22121 (Double free in gdImageSetStyle() after
overflow-triggered early return). (iliaal)
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 2fbfe6e14f7..08a91a6318e 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -5125,7 +5125,7 @@ static bool date_period_init_iso8601_string(php_period_obj *dpobj, zend_class_en
zend_string_release(func);
return false;
}
- if (dpobj->end == NULL && recurrences == 0) {
+ if (dpobj->end == NULL && *recurrences == 0) {
zend_string *func = get_active_function_or_method_name();
zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0, "%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr);
zend_string_release(func);
diff --git a/ext/date/tests/date_period_bad_iso_format.phpt b/ext/date/tests/date_period_bad_iso_format.phpt
index cf2025bef0e..1ab8197d76c 100644
--- a/ext/date/tests/date_period_bad_iso_format.phpt
+++ b/ext/date/tests/date_period_bad_iso_format.phpt
@@ -50,5 +50,5 @@
DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
-DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
-DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): Recurrence count must be greater or equal to 1 and lower than %d
+DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must contain an end date or a recurrence count, "2012-07-01T00:00:00Z/P7D" given
+DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an end date or a recurrence count, "2012-07-01T00:00:00Z/P7D" given