From 7445b0f6d92a78a784df1037445455d345e5697e Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Wed, 14 Jan 2026 18:38:37 +0100 Subject: [PATCH 1/2] Fix GH-20936: DatePeriod::__set_state() cannot handle null start The "current" and "end" field also rely on start_ce, which is set by "start". Therefore, if "current" or "end" are provided, so must "start" be provided. Closes GH-20939. --- NEWS | 4 ++++ ext/date/php_date.c | 4 ++-- ext/date/tests/gh20936.phpt | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 ext/date/tests/gh20936.phpt diff --git a/NEWS b/NEWS index 6416ddedb980..81d0a689972e 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,10 @@ PHP NEWS . Fixed bug GH-21023 (CURLOPT_XFERINFOFUNCTION crash with a null callback). (David Carlier) +- Date: + . Fixed bug GH-20936 (DatePeriod::__set_state() cannot handle null start). + (ndossche) + - DOM: . Fixed bug GH-21077 (Accessing Dom\Node::baseURI can throw TypeError). (ndossche) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 6d0f0428f08d..a67a58bcf923 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -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; } @@ -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; } 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 From 81ef9770be193c64f068a4abd9d0232484bfdd97 Mon Sep 17 00:00:00 2001 From: Djim Schaap <93537121+DjimSchaap@users.noreply.github.com> Date: Wed, 4 Feb 2026 23:03:29 +0100 Subject: [PATCH 2/2] Fix typo in writing-tests.rst (GH-21133) --- docs/source/miscellaneous/writing-tests.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: