[php-src] master: Merge branch 'PHP-8.6'
| From: | Jorg Sowa | Date: | Wed, 18 Nov 2026 22:20:20 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143859@lists.php.net to get a copy of this message | ||
Author: Jorg Sowa (jorgsowa)
Date: 2026-11-18T23:12:45+01:00
Commit: https://github.com/php/php-src/commit/55434182a0607d7dac8178dcae3d3237fbd6b8fa
Raw diff: https://github.com/php/php-src/commit/55434182a0607d7dac8178dcae3d3237fbd6b8fa.diff
Merge branch 'PHP-8.6'
# Conflicts:
# NEWS
Changed paths:
A ext/date/tests/createFromFormat_offset_over_99_hours.phpt
M ext/date/php_date.c
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index c44a608875a7..25526152b34b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1907,27 +1907,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"