|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Submitted: 2018-09-27 17:00 UTC Modified: 2018-10-05 20:40 UTC
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:1 (33.3%)
From: bassemnassief at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 7.1.22 OS: Linux 2.6.32-696.23.1.el6.x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bassemnassief at gmail dot com
New email:
PHP Version: OS:


 [2018-09-27 17:00 UTC] bassemnassief at gmail dot com

After upgrading to PHP 7.1.22, I got the following error

>> Uncaught Exception: U_ARGUMENT_TYPE_MISMATCH

and after doing some tests I found that ICU version 4.2.1 seems to be not compatible with PHP 7.1 although it is mentioned that it should work with ICU library version 4.0.0 or newer as mentioned here


Test script:

$locale = 'nl';
$message = '{0,number,#,###.##} MB';
$vars = [

$formatter = new MessageFormatter($locale, $message);
if (!$formatter) {
    throw new Exception(intl_get_error_message(), intl_get_error_code());

$result = $formatter->format($vars);
if ($result === false) {
    throw new Exception($formatter->getErrorMessage(), $formatter->getErrorCode());

echo $result;

Expected result:
7,12 MB

Actual result:
PHP Fatal error:  Uncaught Exception: U_ARGUMENT_TYPE_MISMATCH in file.php:16
Stack trace:
#0 {main}
  thrown in file.php on line 16


php-7.1.22-msgformatter.patch (last revision 2018-10-01 13:33 UTC by anthrax at unixuser dot org)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-01 12:58 UTC] anthrax at unixuser dot org
It seems to be a problem caused by Fixed BUG #74484
That fix is ​​probably needed in icu-4.8 or later.
 [2018-10-01 19:59 UTC] bassemnassief at gmail dot com
Will your patch allow ICU version 4.2.1 to work again?
 [2018-10-03 18:07 UTC]
-Status: Open +Status: Feedback
 [2018-10-03 18:07 UTC]
@bassemnassief at gmail dot com thanks for the report. Indeed it's documented to be 4.0 compatible, but in most case some newer ICU versions are far more widely used. Given there is a lot of rapid change, in the data and Unicode support and elsewise, perhaps it were long overdue to switch ;)

@anthrax at unixuser dot org I'm not sure the ticket you've mentioned is related. Also the APIs used in that patch available as of ICU 4.0 already, so why should it be included only with 4.8? Could you elaborate please?

 [2018-10-04 07:42 UTC] anthrax at unixuser dot org
In "RHEL 6/CentOS 6" ICU-4.2.1 is used, there is a problem when using PHP 7.1.22 in that environment.

I think this is a FIX of ICU BUG .
It checks with argTypeCount from ICU-4.8, and before that it checks subformatCount
So it was supposed to be included only in 4.8.

And as shown in this BUG report, U_ARGUMENT_TYPE_MISMATCH may be returned in getFormatNames before ICU-4.8
 [2018-10-04 18:13 UTC]
-Status: Feedback +Status: Open
 [2018-10-04 18:13 UTC]
I still don't see the connection. The linked ICU ticket was reported to the time of PHP bug. It's reported against ICU 50. On the corresponding system you can check, whether #74484 reproduces. Most likely it is present in any ICU version. The patch from #74484 uses APIs already available since 4.0 or earlier.

This bug doesn't say anything about 10 and more formats and the reproducer works as expected on newer ICU versions. By best will, it looks like another issue with an older ICU version.

 [2018-10-05 05:15 UTC] anthrax at unixuser dot org
The API used by patch # 74474 is from 4.0 or earlier, but U_ARGUMENT_TYPE_MISMATCH is returned.
I guess there is no API compatibility. tried?
It is different that API exists and works well, is not it?

Implementation of getFormats is different from ICU 4.8 + and earlier.

before ICU-4.8:
    if (formatAliases == NULL) {
        t->formatAliasesCapacity = (subformatCount<10) ? 10 : subformatCount;
        Format** a = (Format**)
uprv_malloc(sizeof(Format*) * formatAliasesCapacity);

    if (formatAliases == NULL) {
        t->formatAliasesCapacity = (argTypeCount<10) ? 10 : argTypeCount;
        Format** a = (Format**)
uprv_malloc(sizeof(Format*) * formatAliasesCapacity);

I think that checking subformatCount is correct, is not it?
 [2018-10-05 20:40 UTC]
@anthrax you are right. I'm going to apply your patch.

That part of the ICU API is very buggy. FYI for master the lowest is ICU 50.

 [2018-10-05 20:55 UTC]
Automatic comment on behalf of ab
 [2018-10-05 20:55 UTC]
-Status: Open +Status: Closed
 [2018-10-06 06:36 UTC] bassemnassief at gmail dot com
Will this patch allow ICU version 4.2.1 to work again like before?
 [2018-10-11 09:30 UTC] anthrax at unixuser dot org
@bassemnassief at gmail dot com
 [2018-10-23 05:45 UTC] bassemnassief at gmail dot com
I upgraded to 7.1.23 but the problem still exists.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Oct 04 10:01:25 2023 UTC