From 6913b7258f1b6894893fb9523f61647c55e100c7 Mon Sep 17 00:00:00 2001 From: lazerg Date: Thu, 12 Nov 2026 09:00:09 +0500 Subject: [PATCH 1/2] Fix GH-25388: Stale ext/date tz cache after logging during startup --- ext/date/php_date.c | 6 +++++- ext/date/tests/gh25388.phpt | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ext/date/tests/gh25388.phpt diff --git a/ext/date/php_date.c b/ext/date/php_date.c index d97dc0825937..d9e4492b1560 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -407,7 +407,6 @@ PHP_RINIT_FUNCTION(date) efree(DATEG(timezone)); } DATEG(timezone) = NULL; - DATEG(tzcache) = NULL; DATEG(last_errors) = NULL; return SUCCESS; @@ -499,6 +498,11 @@ static timelib_tzinfo *php_date_parse_tzfile(const char *formal_tzname, const ti timelib_tzinfo *tzi; int dummy_error_code; + /* Startup memory is released before the first request, so don't cache it */ + if (!EG(active)) { + return timelib_parse_tzfile(formal_tzname, tzdb, &dummy_error_code); + } + if(!DATEG(tzcache)) { ALLOC_HASHTABLE(DATEG(tzcache)); zend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); diff --git a/ext/date/tests/gh25388.phpt b/ext/date/tests/gh25388.phpt new file mode 100644 index 000000000000..f989b82ceebb --- /dev/null +++ b/ext/date/tests/gh25388.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-25388 (Invalid access or leak of ext/date tz cache after logging during startup) +--CREDITS-- +bwoebi +--INI-- +allow_url_include=1 +log_errors=1 +error_log={PWD}/gh25388.log +output_handler=inexistent +date.timezone=Europe/Berlin +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 + +Warning: PHP Request Startup: function "inexistent" not found or invalid function name in Unknown on line 0 +Europe/Berlin From 3517fdcbe013d10d849d45c58eb0a9f505960a1f Mon Sep 17 00:00:00 2001 From: lazerg Date: Thu, 12 Nov 2026 09:04:55 +0500 Subject: [PATCH 2/2] Use the issue title in the GH-25388 test --- ext/date/tests/gh25388.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/date/tests/gh25388.phpt b/ext/date/tests/gh25388.phpt index f989b82ceebb..84dcdda15658 100644 --- a/ext/date/tests/gh25388.phpt +++ b/ext/date/tests/gh25388.phpt @@ -1,5 +1,5 @@ --TEST-- -GH-25388 (Invalid access or leak of ext/date tz cache after logging during startup) +GH-25388 (Invalid access or leak of startup data for ext/date after early usage (php_log_err in minit+rinit)) --CREDITS-- bwoebi --INI-- @@ -16,7 +16,7 @@ echo date('e'), "\n"; ---EXPECTF-- +--EXPECT-- Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 Warning: PHP Request Startup: function "inexistent" not found or invalid function name in Unknown on line 0