1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix GH-20936: DatePeriod::__set_state() cannot handle null start
This commit is contained in:
ndossche
2026-02-04 18:36:17 +01:00
2 changed files with 16 additions and 2 deletions

View File

@@ -5747,7 +5747,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con
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 false;
}
@@ -5768,7 +5768,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con
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 false;
}

View File

@@ -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