Skip to content

Commit 19273ff

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-8364: msgfmt_format $values may not support references
2 parents 5328589 + 1c0dc2a commit 19273ff

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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)