Skip to content

Commit 1c0dc2a

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-8364: msgfmt_format $values may not support references
2 parents 8da14a3 + f5d9e7c commit 1c0dc2a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ PHP NEWS
2626
- Hash:
2727
. Fixed bug #81714 (segfault when serializing finalized HashContext). (cmb)
2828

29+
- Intl:
30+
. Fixed bug GH-8364 (msgfmt_format $values may not support references). (cmb)
31+
2932
- MBString:
3033
. Number of error markers emitted for invalid UTF-8 text matches WHATWG specification.
3134
This is a return to the behavior of PHP 8.0 and earlier. (alexdowad)

ext/intl/msgformat/msgformat_helpers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
392392
zend_ulong num_index;
393393

394394
ZEND_HASH_FOREACH_KEY_VAL(args, num_index, str_index, elem) {
395+
ZVAL_DEREF(elem);
395396
Formattable& formattable = fargs[argNum];
396397
UnicodeString& key = farg_names[argNum];
397398
Formattable::Type argType = Formattable::kObject, //unknown

ext/intl/tests/gh8364.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug GH-8364 (msgfmt_format $values may not support references)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("intl")) die("skip intl extension not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$formatter = new MessageFormatter('en', 'translate {0}');
10+
$args = ['string', 'string'];
11+
foreach ($args as &$arg) {
12+
// do nothing;
13+
}
14+
$result = $formatter->format($args);
15+
var_dump($result);
16+
var_dump(intl_get_error_code());
17+
?>
18+
--EXPECT--
19+
string(16) "translate string"
20+
int(0)

0 commit comments

Comments
 (0)