[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Wed, 18 Nov 2026 22:20:18 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143856@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-11-18T23:12:20+01:00 Commit: https://github.com/php/php-src/commit/2c5c25dddfc96b67e004fd63011ff8ba04f5074f Raw diff: https://github.com/php/php-src/commit/2c5c25dddfc96b67e004fd63011ff8ba04f5074f.diff Merge branch 'PHP-8.4' into PHP-8.5 Changed paths: A ext/date/tests/createFromFormat_offset_over_99_hours.phpt M NEWS M ext/date/php_date.c Diff: diff --git a/NEWS b/NEWS index f97b7eee1247..f9aff8c17780 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,10 @@ PHP NEWS - Curl: . Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire) +- Date: + . Fixed truncated timezone name for UTC offsets of 100 hours or more + created by DateTime::createFromFormat(). (Jorg Sowa) + - DBA: . Fixed dba_close() not closing a database opened with dba_popen(). (Ilia Alshanetsky) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index c36439b11743..77719fd8563a 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1904,27 +1904,20 @@ static HashTable *date_object_get_gc_timezone(zend_object *object, zval **table, static zend_string *date_create_tz_offset_str(timelib_sll offset) { int seconds = offset % 60; - size_t size; const char *format; if (seconds == 0) { - size = sizeof("+05:00"); format = "%c%02d:%02d"; } else { - size = sizeof("+05:00:01"); format = "%c%02d:%02d:%02d"; } - zend_string *tmpstr = zend_string_alloc(size - 1, 0); - /* Note: if seconds == 0, the seconds argument will be excessive and therefore ignored. */ - ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), size, format, + return zend_strpprintf(0, format, offset < 0 ? '-' : '+', abs((int)(offset / 3600)), abs((int)(offset % 3600) / 60), abs(seconds)); - - return tmpstr; } static void date_object_to_hash(php_date_obj *dateobj, HashTable *props) diff --git a/ext/date/tests/createFromFormat_offset_over_99_hours.phpt b/ext/date/tests/createFromFormat_offset_over_99_hours.phpt new file mode 100644 index 000000000000..4b0cf72c184c --- /dev/null +++ b/ext/date/tests/createFromFormat_offset_over_99_hours.phpt @@ -0,0 +1,8 @@ +--TEST-- +DateTime::createFromFormat() with UTC offset of 100 hours or more +--FILE-- +<?php +var_dump(DateTime::createFromFormat('O', '+9999')->getTimezone()->getName()); +?> +--EXPECT-- +string(7) "+100:39"

« previous php.cvs (#143856) next »