Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -5811,7 +5811,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, Has
php_date_obj *date_obj;
date_obj = Z_PHPDATE_P(ht_entry);

if (!date_obj->time) {
if (!date_obj->time || !period_obj->start_ce) {
return 0;
}

Expand All @@ -5832,7 +5832,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, Has
php_date_obj *date_obj;
date_obj = Z_PHPDATE_P(ht_entry);

if (!date_obj->time) {
if (!date_obj->time || !period_obj->start_ce) {
return 0;
}

Expand Down
14 changes: 14 additions & 0 deletions ext/date/tests/gh20936.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
GH-20936 (DatePeriod::__set_state() cannot handle null start)
--FILE--
<?php
$end = new DateTime('2022-07-16', new DateTimeZone('UTC'));
$interval = new DateInterval('P2D');
try {
DatePeriod::__set_state(['start' => null, 'end' => $end, 'current' => null, 'interval' => $interval, 'recurrences' => 2, 'include_start_date' => false, 'include_end_date' => true]);
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}
?>
--EXPECT--
Error: Invalid serialization data for DatePeriod object
Loading