Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GH-16814: MessageFormatter::format throws an error on invalid arr… #16816

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/intl/msgformat/msgformat_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
* as a result of that.
*/
str = zval_get_tmp_string(elem, &tmp_str);
if (!str || !ZSTR_LEN(str)) {
EG(exception) = NULL;
return;
}

UnicodeString *text = new UnicodeString();
intl_stringFromChar(*text,
Expand Down
12 changes: 12 additions & 0 deletions ext/intl/tests/gh16814.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-16814 (MessageFormatter::format throws error on unused parameter)
--EXTENSIONS--
intl
--FILE--
<?php
$fmt = new MessageFormatter('de', 'Beispiel ohne Benutzung');
$fmt->format(['payed' => new DateTimeImmutable()]);
echo "OK";
?>
--EXPECT--
OK
Loading