php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76942 U_ARGUMENT_TYPE_MISMATCH
Submitted: 2018-09-27 17:00 UTC Modified: 2018-10-05 20:40 UTC
Votes:3
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
 [2018-09-27 17:00 UTC] bassemnassief at gmail dot com
Description:
------------
Hello,

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 http://php.net/manual/en/intl.requirements.php

Thanks

Test script:
---------------
<?php

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

$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


Patches

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

History

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
@anthrax
Will your patch allow ICU version 4.2.1 to work again?
 [2018-10-03 18:07 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2018-10-03 18:07 UTC] ab@php.net
@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?

Thanks.
 [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 https://unicode-org.atlassian.net/browse/ICU-12584 .
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] ab@php.net
-Status: Feedback +Status: Open
 [2018-10-04 18:13 UTC] ab@php.net
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.

Thanks.
 [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?

Also,
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);
```

ICU-4.8+:
```
    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] ab@php.net
@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.

Thanks.
 [2018-10-05 20:55 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=534684d1042978f3c21caf9b665a7aca27f3f325
Log: Fixed Bug #76942 U_ARGUMENT_TYPE_MISMATCH
 [2018-10-05 20:55 UTC] ab@php.net
-Status: Open +Status: Closed
 [2018-10-06 06:36 UTC] bassemnassief at gmail dot com
@ab
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
yes
 [2018-10-23 05:45 UTC] bassemnassief at gmail dot com
@ab@php.net
I upgraded to 7.1.23 but the problem still exists.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Nov 14 15:01:27 2018 UTC