[php-src] master: Merge branch 'PHP-8.5'

From: Date: Sun, 13 Sep 2026 14:12:35 +0000
Subject: [php-src] master: Merge branch 'PHP-8.5'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141181@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-09-13T10:08:47-04:00 Commit: https://github.com/php/php-src/commit/4bc9c1b1d60c17015ab64e9e107e90c511abfa7c Raw diff: https://github.com/php/php-src/commit/4bc9c1b1d60c17015ab64e9e107e90c511abfa7c.diff Merge branch 'PHP-8.5' * PHP-8.5: ext/intl: Preserve PHP-side state when cloning formatters Changed paths: A ext/intl/tests/clone_preserves_php_fields.phpt M NEWS M ext/intl/dateformat/dateformat_class.cpp M ext/intl/msgformat/msgformat_class.cpp Diff: diff --git a/NEWS b/NEWS index 5182713edfc5..8969824fe760 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,11 @@ PHP NEWS registrations are freed while still reachable from the cycle collector. (Ilia Alshanetsky) +- Intl: + . Fixed cloning IntlDateFormatter and MessageFormatter losing PHP-side state + such as dateType, timeType, calendar and the message pattern. + (Ilia Alshanetsky) + - MBString: . Fixed bug GH-23106 (mb_strpos() reads past the end of a haystack ending in a truncated UTF-8 sequence). (Lazizbek Ergashev) diff --git a/ext/intl/dateformat/dateformat_class.cpp b/ext/intl/dateformat/dateformat_class.cpp index e9869612b873..45a6c56cc1c3 100644 --- a/ext/intl/dateformat/dateformat_class.cpp +++ b/ext/intl/dateformat/dateformat_class.cpp @@ -73,6 +73,13 @@ zend_object *IntlDateFormatter_object_clone(zend_object *object) /* clone standard parts */ zend_objects_clone_members(&new_dfo->zo, &dfo->zo); + new_dfo->date_type = dfo->date_type; + new_dfo->time_type = dfo->time_type; + new_dfo->calendar = dfo->calendar; + if (dfo->requested_locale != NULL) { + new_dfo->requested_locale = estrdup(dfo->requested_locale); + } + /* clone formatter object */ if (DATE_FORMAT_OBJECT(dfo) != NULL) { UErrorCode error = U_ZERO_ERROR; diff --git a/ext/intl/msgformat/msgformat_class.cpp b/ext/intl/msgformat/msgformat_class.cpp index c4d74924b04a..52f6c79df8cd 100644 --- a/ext/intl/msgformat/msgformat_class.cpp +++ b/ext/intl/msgformat/msgformat_class.cpp @@ -65,6 +65,12 @@ U_CFUNC zend_object *MessageFormatter_object_clone(zend_object *object) /* clone standard parts */ zend_objects_clone_members(&new_mfo->zo, &mfo->zo); + if (mfo->mf_data.orig_format != NULL) { + new_mfo->mf_data.orig_format = estrndup(mfo->mf_data.orig_format, mfo->mf_data.orig_format_len); + new_mfo->mf_data.orig_format_len = mfo->mf_data.orig_format_len; + } + new_mfo->mf_data.tz_set = mfo->mf_data.tz_set; + /* clone formatter object */ if (MSG_FORMAT_OBJECT(mfo) != NULL) { UErrorCode error = U_ZERO_ERROR; diff --git a/ext/intl/tests/clone_preserves_php_fields.phpt b/ext/intl/tests/clone_preserves_php_fields.phpt new file mode 100644 index 000000000000..1c57ce539ad6 --- /dev/null +++ b/ext/intl/tests/clone_preserves_php_fields.phpt @@ -0,0 +1,37 @@ +--TEST-- +Cloning IntlDateFormatter and MessageFormatter preserves PHP-side fields +--EXTENSIONS-- +intl +--FILE-- +<?php +$d = new IntlDateFormatter('de_DE', IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, 'UTC', IntlDateFormatter::GREGORIAN); +$c = clone $d; +var_dump($c->getDateType()); +var_dump($c->getTimeType()); +var_dump($c->getCalendar()); +var_dump($c->format(strtotime('2024-01-02 03:04:05 UTC'))); +$c->setCalendar(IntlDateFormatter::GREGORIAN); +var_dump($c->getPattern()); + +$m = new MessageFormatter('en_US', '{0, number}'); +$mc = clone $m; +var_dump($mc->getPattern()); +var_dump($mc->format([1.5])); + +date_default_timezone_set('UTC'); +$t = new MessageFormatter('en_US', '{0,time,short}'); +$dt = new DateTimeImmutable('2024-01-02 03:04:05', new DateTimeZone('UTC')); +$t->format([$dt]); +$tc = clone $t; +date_default_timezone_set('America/New_York'); +var_dump($t->format([$dt]) === $tc->format([$dt])); +?> +--EXPECT-- +int(1) +int(2) +int(1) +string(26) "2. Januar 2024 um 03:04:05" +string(23) "d. MMMM y 'um' HH:mm:ss" +string(11) "{0, number}" +string(3) "1.5" +bool(true)

« previous php.cvs (#141181) next »