diff --git a/docs/source/miscellaneous/writing-tests.rst b/docs/source/miscellaneous/writing-tests.rst index 8c4e0535763c..dae6c1d861ef 100644 --- a/docs/source/miscellaneous/writing-tests.rst +++ b/docs/source/miscellaneous/writing-tests.rst @@ -235,7 +235,7 @@ and not in the INI section. This is because of the order in which settings are c date_default_timezone_set() -> TZ environmental -> INI setting -> System Setting -If a TZ environmental varaibale is found the INI setting will be ignored. +If a TZ environmental variable is found the INI setting will be ignored. Tests that run, or only have have matching EXPECT output, on 32bit platforms can use a SKIPIF section like: diff --git a/ext/date/php_date.c b/ext/date/php_date.c index e462b70d2cff..c811c2493a01 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -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; } diff --git a/ext/date/tests/gh20936.phpt b/ext/date/tests/gh20936.phpt new file mode 100644 index 000000000000..e6a525dd4583 --- /dev/null +++ b/ext/date/tests/gh20936.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-20936 (DatePeriod::__set_state() cannot handle null start) +--FILE-- + 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