Skip to content

Commit 34a341e

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix GH-20936: DatePeriod::__set_state() cannot handle null start
2 parents 52eb174 + 7445b0f commit 34a341e

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fixed bug GH-20504 (Assertion failure in zend_get_property_guard when
1515
accessing properties on Reflection LazyProxy via isset()). (Arnaud)
1616

17+
- Date:
18+
. Fixed bug GH-20936 (DatePeriod::__set_state() cannot handle null start).
19+
(ndossche)
20+
1721
- DOM:
1822
. Fixed bug GH-21077 (Accessing Dom\Node::baseURI can throw TypeError).
1923
(ndossche)

ext/date/php_date.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5749,7 +5749,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con
57495749
php_date_obj *date_obj;
57505750
date_obj = Z_PHPDATE_P(ht_entry);
57515751

5752-
if (!date_obj->time) {
5752+
if (!date_obj->time || !period_obj->start_ce) {
57535753
return 0;
57545754
}
57555755

@@ -5770,7 +5770,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con
57705770
php_date_obj *date_obj;
57715771
date_obj = Z_PHPDATE_P(ht_entry);
57725772

5773-
if (!date_obj->time) {
5773+
if (!date_obj->time || !period_obj->start_ce) {
57745774
return 0;
57755775
}
57765776

ext/date/tests/gh20936.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-20936 (DatePeriod::__set_state() cannot handle null start)
3+
--FILE--
4+
<?php
5+
$end = new DateTime('2022-07-16', new DateTimeZone('UTC'));
6+
$interval = new DateInterval('P2D');
7+
try {
8+
DatePeriod::__set_state(['start' => null, 'end' => $end, 'current' => null, 'interval' => $interval, 'recurrences' => 2, 'include_start_date' => false, 'include_end_date' => true]);
9+
} catch (Throwable $e) {
10+
echo $e::class, ": ", $e->getMessage(), "\n";
11+
}
12+
?>
13+
--EXPECT--
14+
Error: Invalid serialization data for DatePeriod object

0 commit comments

Comments
 (0)