From: Nikita Popov Date: Mon, 12 Oct 2020 14:44:18 +0000 (+0200) Subject: Merge branch 'PHP-7.4' into PHP-8.0 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6edad1716da48ac4765089d8603a4178b852afd8;p=php Merge branch 'PHP-7.4' into PHP-8.0 * PHP-7.4: intl: report more information about message pattern parse errors --- 6edad1716da48ac4765089d8603a4178b852afd8 diff --cc ext/intl/msgformat/msgformat.c index cb625ed037,edf69dc52c..fdb366c1b1 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@@ -34,6 -36,8 +34,7 @@@ static int msgfmt_ctor(INTERNAL_FUNCTIO int spattern_len = 0; zval* object; MessageFormatter_object* mfo; + UParseError parse_error; - int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0; intl_error_reset( NULL ); object = return_value; @@@ -103,9 -129,11 +118,11 @@@ PHP_METHOD( MessageFormatter, __constru zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling); return_value = ZEND_THIS; - if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) { + if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); + zend_string *err = intl_error_get_message(NULL); + zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL)); + zend_string_release_ex(err, 0); } } zend_restore_error_handling(&error_handling); diff --cc ext/intl/tests/msgfmt_fail2.phpt index 4061eab3dc,0d4a52a64f..f604de0727 --- a/ext/intl/tests/msgfmt_fail2.phpt +++ b/ext/intl/tests/msgfmt_fail2.phpt @@@ -108,25 -78,25 +108,25 @@@ foreach($args as $arg) ?> --EXPECTF-- -ArgumentCountError: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +ArgumentCountError: MessageFormatter::__construct() expects exactly 2 arguments, 0 given in %s on line %d +'U_ZERO_ERROR' -Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +ArgumentCountError: msgfmt_create() expects exactly 2 arguments, 0 given in %s on line %d +'U_ZERO_ERROR' -Warning: MessageFormatter::create() expects exactly 2 parameters, 0 given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +ArgumentCountError: MessageFormatter::create() expects exactly 2 arguments, 0 given in %s on line %d +'U_ZERO_ERROR' -ArgumentCountError: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +ArgumentCountError: MessageFormatter::__construct() expects exactly 2 arguments, 1 given in %s on line %d +'U_ZERO_ERROR' -Warning: msgfmt_create() expects exactly 2 parameters, 1 given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +ArgumentCountError: msgfmt_create() expects exactly 2 arguments, 1 given in %s on line %d +'U_ZERO_ERROR' -Warning: MessageFormatter::create() expects exactly 2 parameters, 1 given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +ArgumentCountError: MessageFormatter::create() expects exactly 2 arguments, 1 given in %s on line %d +'U_ZERO_ERROR' - IntlException: Constructor failed in %s on line %d + IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d 'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' @@@ -136,21 -106,21 +136,21 @@@ IntlException: msgfmt_create: message f 'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' 'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' -TypeError: MessageFormatter::__construct() expects parameter 1 to be string, array given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +TypeError: MessageFormatter::__construct(): Argument #1 ($locale) must be of type string, array given in %s on line %d +'U_ZERO_ERROR' -Warning: MessageFormatter::create() expects parameter 1 to be string, array given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +TypeError: MessageFormatter::create(): Argument #1 ($locale) must be of type string, array given in %s on line %d +'U_ZERO_ERROR' -Warning: msgfmt_create() expects parameter 1 to be string, array given in %s on line %d -'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR' +TypeError: msgfmt_create(): Argument #1 ($locale) must be of type string, array given in %s on line %d +'U_ZERO_ERROR' - IntlException: Constructor failed in %s on line %d - 'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR' - 'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR' - 'msgfmt_create: message formatter creation failed: U_PATTERN_SYNTAX_ERROR' + IntlException: pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR in %s on line %d + 'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' + 'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' + 'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' - IntlException: Constructor failed in %s on line %d + IntlException: msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES in %s on line %d 'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' 'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' 'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES'