[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Jorg Sowa | Date: | Wed, 18 Nov 2026 22:20:20 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143858@lists.php.net to get a copy of this message | ||
Author: Jorg Sowa (jorgsowa)
Date: 2026-11-18T23:12:39+01:00
Commit: https://github.com/php/php-src/commit/bc5e00b9fe2b14e00849320332e4051d99cc23f2
Raw diff: https://github.com/php/php-src/commit/bc5e00b9fe2b14e00849320332e4051d99cc23f2.diff
Merge branch 'PHP-8.5' into PHP-8.6
# Conflicts:
# NEWS
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 24ee7cdb0f85..5a90f780e75f 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,8 @@ PHP NEWS
- Date:
. Update timelib to 2026.03 (Derick)
+ . 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().
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 415b7f4fbd74..b040cf51edac 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1909,27 +1909,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"