summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/intl/breakiterator/breakiterator_methods.cpp4
-rw-r--r--ext/intl/calendar/gregoriancalendar_methods.cpp38
-rw-r--r--ext/intl/collator/collator_create.c12
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp20
-rw-r--r--ext/intl/formatter/formatter_main.c14
-rw-r--r--ext/intl/intl_common.h2
-rw-r--r--ext/intl/intl_data.h4
-rw-r--r--ext/intl/intl_error.c57
-rw-r--r--ext/intl/intl_error.h6
-rw-r--r--ext/intl/msgformat/msgformat.c16
-rw-r--r--ext/intl/msgformat/msgformat_class.c4
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c14
-rw-r--r--ext/intl/spoofchecker/spoofchecker_create.c2
-rw-r--r--ext/intl/tests/bug62017.phpt12
-rw-r--r--ext/intl/tests/formatter_fail.phpt53
-rw-r--r--ext/intl/tests/formatter_format.phpt9
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_error.phpt22
-rw-r--r--ext/intl/tests/msgfmt_fail.phpt61
-rw-r--r--ext/intl/tests/msgfmt_parse.phpt14
-rw-r--r--ext/intl/tests/resourcebundle_create.phpt29
-rw-r--r--ext/intl/transliterator/transliterator_methods.c8
21 files changed, 250 insertions, 151 deletions
diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp
index baab5a682d..02d228653a 100644
--- a/ext/intl/breakiterator/breakiterator_methods.cpp
+++ b/ext/intl/breakiterator/breakiterator_methods.cpp
@@ -162,12 +162,12 @@ U_CFUNC PHP_FUNCTION(breakiter_set_text)
BREAKITER_METHOD_FETCH_OBJECT;
ut = utext_openUTF8(ut, text->val, text->len, BREAKITER_ERROR_CODE_P(bio));
- INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error opening UText");
+ INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error opening UText", 0);
bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio));
utext_close(ut); /* ICU shallow clones the UText */
INTL_CTOR_CHECK_STATUS(bio, "breakiter_set_text: error calling "
- "BreakIterator::setText()");
+ "BreakIterator::setText()", 0);
/* When ICU clones the UText, it does not copy the buffer, so we have to
* keep the string buffer around by holding a reference to its zval. This
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp
index 2ae5737227..69bae08e06 100644
--- a/ext/intl/calendar/gregoriancalendar_methods.cpp
+++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
@@ -36,7 +36,7 @@ static inline GregorianCalendar *fetch_greg(Calendar_object *co) {
return (GregorianCalendar*)co->ucal;
}
-static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
+static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
zval *tz_object = NULL;
zval args_a[6] = {0},
@@ -51,8 +51,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
// parameter number validation / variant determination
if (ZEND_NUM_ARGS() > 6 ||
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlgregcal_create_instance: too many arguments", 0);
+ intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: too many arguments", 0, is_constructor);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -60,9 +60,9 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
variant > 0 && Z_TYPE(args[variant - 1]) == IS_NULL;
variant--) {}
if (variant == 4) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: no variant with 4 arguments "
- "(excluding trailing NULLs)", 0);
+ "(excluding trailing NULLs)", 0, is_constructor);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -71,8 +71,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
if (variant <= 2) {
if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2),
"|z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlgregcal_create_instance: bad arguments", 0);
+ intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: bad arguments", 0, is_constructor);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -80,8 +80,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS(),
"lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
&largs[5]) == FAILURE) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlgregcal_create_instance: bad arguments", 0);
+ intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: bad arguments", 0, is_constructor);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -104,8 +104,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
status);
if (U_FAILURE(status)) {
- intl_error_set(NULL, status, "intlgregcal_create_instance: error "
- "creating ICU GregorianCalendar from time zone and locale", 0);
+ intl_error_set_ex(NULL, status, "intlgregcal_create_instance: error "
+ "creating ICU GregorianCalendar from time zone and locale", 0, is_constructor);
if (gcal) {
delete gcal;
}
@@ -117,9 +117,9 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
// From date/time (3, 5 or 6 arguments)
for (int i = 0; i < variant; i++) {
if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: at least one of the arguments"
- " has an absolute value that is too large", 0);
+ " has an absolute value that is too large", 0, is_constructor);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -137,8 +137,8 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
status);
}
if (U_FAILURE(status)) {
- intl_error_set(NULL, status, "intlgregcal_create_instance: error "
- "creating ICU GregorianCalendar from date", 0);
+ intl_error_set_ex(NULL, status, "intlgregcal_create_instance: error "
+ "creating ICU GregorianCalendar from date", 0, is_constructor);
if (gcal) {
delete gcal;
}
@@ -154,10 +154,10 @@ static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
strlen(tzinfo->name), US_INV);
#endif
if (tzstr.isBogus()) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set_ex(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_create_instance: could not create UTF-8 string "
"from PHP's default timezone name (see date_default_timezone_get())",
- 0);
+ 0, is_constructor);
delete gcal;
Z_OBJ_P(return_value) = NULL;
return;
@@ -179,7 +179,7 @@ U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
object_init_ex(return_value, GregorianCalendar_ce_ptr);
ZVAL_COPY_VALUE(&orig, return_value);
- _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zval_dtor(&orig);
@@ -194,7 +194,7 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct)
return_value = getThis();
//changes this to IS_NULL (without first destroying) if there's an error
- _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this));
diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c
index b2058422c2..7631d76ff4 100644
--- a/ext/intl/collator/collator_create.c
+++ b/ext/intl/collator/collator_create.c
@@ -25,7 +25,7 @@
#include "intl_data.h"
/* {{{ */
-static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char* locale;
size_t locale_len = 0;
@@ -38,8 +38,8 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s",
&locale, &locale_len ) == FAILURE )
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "collator_create: unable to parse input params", 0 );
+ intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "collator_create: unable to parse input params", 0, is_constructor );
zval_dtor(return_value);
RETURN_NULL();
}
@@ -53,7 +53,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
/* Open ICU collator. */
co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
- INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
+ INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator", is_constructor);
}
/* }}} */
@@ -63,7 +63,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
PHP_FUNCTION( collator_create )
{
object_init_ex( return_value, Collator_ce_ptr );
- collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
@@ -75,7 +75,7 @@ PHP_METHOD( Collator, __construct )
zval orig_this = *getThis();
return_value = getThis();
- collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this));
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index f8cf77641f..9d6d5f4e97 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -36,7 +36,7 @@ extern "C" {
#include "dateformat_helpers.h"
/* {{{ */
-static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
zval *object;
@@ -64,8 +64,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|zzs",
&locale_str, &locale_len, &date_type, &time_type, &timezone_zv,
&calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
- "unable to parse input parameters", 0);
+ intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
+ "unable to parse input parameters", 0, is_constructor);
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -79,6 +79,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
if (DATE_FORMAT_OBJECT(dfo) != NULL) {
+ // This is __construct being called on an instance - it is not
+ // a constructor.
intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_create: cannot call constructor twice", 0);
return;
@@ -110,8 +112,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
/* object construction -> only set global error */
- intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
- "error converting pattern to UTF-16", 0);
+ intl_error_set_ex(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
+ "error converting pattern to UTF-16", 0, is_constructor);
goto error;
}
}
@@ -139,8 +141,8 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
df->adoptTimeZone(timezone);
}
} else {
- intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
- "formatter creation failed", 0);
+ intl_error_set_ex(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
+ "formatter creation failed", 0, is_constructor);
goto error;
}
@@ -175,7 +177,7 @@ error:
U_CFUNC PHP_FUNCTION( datefmt_create )
{
object_init_ex( return_value, IntlDateFormatter_ce_ptr );
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
@@ -192,7 +194,7 @@ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct )
/* return_value param is being changed, therefore we will always return
* NULL here */
return_value = getThis();
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this));
diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c
index 60db673ff2..c8ca65da27 100644
--- a/ext/intl/formatter/formatter_main.c
+++ b/ext/intl/formatter/formatter_main.c
@@ -25,7 +25,7 @@
#include "intl_convert.h"
/* {{{ */
-static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char* locale;
char* pattern = NULL;
@@ -39,8 +39,8 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s",
&locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "numfmt_create: unable to parse input parameters", 0 );
+ intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "numfmt_create: unable to parse input parameters", 0, is_constructor );
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -52,7 +52,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
/* Convert pattern (if specified) to UTF-16. */
if(pattern && pattern_len) {
intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(nfo));
- INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: error converting pattern to UTF-16");
+ INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: error converting pattern to UTF-16", is_constructor);
}
if(locale_len == 0) {
@@ -66,7 +66,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
efree(spattern);
}
- INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: number formatter creation failed");
+ INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: number formatter creation failed", is_constructor);
}
/* }}} */
@@ -78,7 +78,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
PHP_FUNCTION( numfmt_create )
{
object_init_ex( return_value, NumberFormatter_ce_ptr );
- numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
@@ -93,7 +93,7 @@ PHP_METHOD( NumberFormatter, __construct )
zval orig_this = *getThis();
return_value = getThis();
- numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this));
diff --git a/ext/intl/intl_common.h b/ext/intl/intl_common.h
index a49794648d..61da2738d1 100644
--- a/ext/intl/intl_common.h
+++ b/ext/intl/intl_common.h
@@ -41,4 +41,6 @@
#define INTL_Z_STRVAL_P(str) (UChar*) Z_STRVAL_P(str)
#define INTL_Z_STRLEN_P(str) UCHARS( Z_STRLEN_P(str) )
+extern zend_class_entry *IntlException_ce_ptr;
+
#endif /* INTL_COMMON_H */
diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h
index 6001aa1285..c49214ffcd 100644
--- a/ext/intl/intl_data.h
+++ b/ext/intl/intl_data.h
@@ -64,11 +64,11 @@ typedef struct _intl_data {
}
/* Check status, if error - destroy value and exit */
-#define INTL_CTOR_CHECK_STATUS(obj, msg) \
+#define INTL_CTOR_CHECK_STATUS(obj, msg, forceException) \
intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
{ \
- intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
+ intl_errors_set_custom_msg_ex( INTL_DATA_ERROR_P((obj)), msg, 0, forceException ); \
/* yes, this is ugly, but it alreay is */ \
if (return_value != getThis()) { \
zval_dtor(return_value); \
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c
index 28a2a244e2..8ea5e7b4cf 100644
--- a/ext/intl/intl_error.c
+++ b/ext/intl/intl_error.c
@@ -29,7 +29,7 @@
ZEND_EXTERN_MODULE_GLOBALS( intl )
-static zend_class_entry *IntlException_ce_ptr;
+zend_class_entry *IntlException_ce_ptr;
/* {{{ intl_error* intl_g_error_get()
* Return global error structure.
@@ -103,14 +103,25 @@ void intl_error_reset( intl_error* err )
*/
void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg )
{
+ intl_error_set_custom_msg_ex( err, msg, copyMsg, 0 );
+}
+/* }}} */
+
+
+/* {{{ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg )
+ * Set last error message to msg copying it if needed.
+ */
+void intl_error_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException )
+{
if( !msg )
return;
if( !err ) {
- if( INTL_G( error_level ) )
- php_error_docref( NULL, INTL_G( error_level ), "%s", msg );
- if( INTL_G( use_exceptions ) )
+ if ( forceException || INTL_G( use_exceptions ) ) {
zend_throw_exception_ex( IntlException_ce_ptr, 0, "%s", msg );
+ } else if( INTL_G( error_level ) ) {
+ php_error_docref( NULL, INTL_G( error_level ), "%s", msg );
+ }
}
if( !err && !( err = intl_g_error_get( ) ) )
return;
@@ -182,18 +193,38 @@ UErrorCode intl_error_get_code( intl_error* err )
*/
void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
{
+ intl_error_set_ex( err, code, msg, copyMsg, 0 );
+}
+/* }}} */
+
+
+/* {{{ void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
+ * Set error code and message.
+ */
+void intl_error_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException )
+{
intl_error_set_code( err, code );
- intl_error_set_custom_msg( err, msg, copyMsg );
+ intl_error_set_custom_msg_ex( err, msg, copyMsg, forceException );
}
/* }}} */
+
/* {{{ void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
* Set error code and message.
*/
void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
{
+ intl_errors_set_ex( err, code, msg, copyMsg, 0 );
+}
+/* }}} */
+
+/* {{{ void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg )
+ * Set error code and message.
+ */
+void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException )
+{
intl_errors_set_code( err, code );
- intl_errors_set_custom_msg( err, msg, copyMsg );
+ intl_errors_set_custom_msg_ex( err, msg, copyMsg, forceException );
}
/* }}} */
@@ -212,13 +243,23 @@ void intl_errors_reset( intl_error* err )
*/
void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg )
{
+ intl_errors_set_custom_msg_ex( err, msg, copyMsg, 0 );
+}
+/* }}} */
+
+
+/* {{{ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg )
+ */
+void intl_errors_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException )
+{
if(err) {
- intl_error_set_custom_msg( err, msg, copyMsg );
+ intl_error_set_custom_msg_ex( err, msg, copyMsg, forceException );
}
- intl_error_set_custom_msg( NULL, msg, copyMsg );
+ intl_error_set_custom_msg_ex( NULL, msg, copyMsg, forceException );
}
/* }}} */
+
/* {{{ intl_errors_set_code( intl_error* err, UErrorCode err_code )
*/
void intl_errors_set_code( intl_error* err, UErrorCode err_code )
diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h
index 02d62f0299..4c9349b281 100644
--- a/ext/intl/intl_error.h
+++ b/ext/intl/intl_error.h
@@ -36,15 +36,21 @@ void intl_error_init( intl_error* err );
void intl_error_reset( intl_error* err );
void intl_error_set_code( intl_error* err, UErrorCode err_code );
void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg );
+void intl_error_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException );
void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg );
+void intl_error_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException );
+
+
UErrorCode intl_error_get_code( intl_error* err );
zend_string* intl_error_get_message( intl_error* err );
// Wrappers to synchonize object's and global error structures.
void intl_errors_reset( intl_error* err );
void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg );
+void intl_errors_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException );
void intl_errors_set_code( intl_error* err, UErrorCode err_code );
void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg );
+void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException );
// Other error helpers
smart_str intl_parse_error_to_string( UParseError* pe );
diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c
index 707b38bd95..34923f92a5 100644
--- a/ext/intl/msgformat/msgformat.c
+++ b/ext/intl/msgformat/msgformat.c
@@ -26,7 +26,7 @@
#include "intl_convert.h"
/* {{{ */
-static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char* locale;
char* pattern;
@@ -42,8 +42,8 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
if( zend_parse_parameters( ZEND_NUM_ARGS(), "ss",
&locale, &locale_len, &pattern, &pattern_len ) == FAILURE )
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "msgfmt_create: unable to parse input parameters", 0 );
+ intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "msgfmt_create: unable to parse input parameters", 0, is_constructor );
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -54,7 +54,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
/* Convert pattern (if specified) to UTF-16. */
if(pattern && pattern_len) {
intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(mfo));
- INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to UTF-16");
+ INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to UTF-16", is_constructor);
} else {
spattern_len = 0;
spattern = NULL;
@@ -66,7 +66,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
#ifdef MSG_FORMAT_QUOTE_APOS
if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
- INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format");
+ INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format", is_constructor);
}
#endif
@@ -84,7 +84,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
efree(spattern);
}
- INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: message formatter creation failed");
+ INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: message formatter creation failed", is_constructor);
}
/* }}} */
@@ -96,7 +96,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
PHP_FUNCTION( msgfmt_create )
{
object_init_ex( return_value, MessageFormatter_ce_ptr );
- msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
@@ -111,7 +111,7 @@ PHP_METHOD( MessageFormatter, __construct )
zval orig_this = *getThis();
return_value = getThis();
- msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this));
diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c
index 8d464c6ca4..1296d087e1 100644
--- a/ext/intl/msgformat/msgformat_class.c
+++ b/ext/intl/msgformat/msgformat_class.c
@@ -87,10 +87,10 @@ zend_object *MessageFormatter_object_clone(zval *object)
if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {
intl_errors_set(INTL_DATA_ERROR_P(mfo), INTL_DATA_ERROR_CODE(mfo),
"Failed to clone MessageFormatter object", 0);
- zend_throw_exception_ex(NULL, 0, "Failed to clone MessageFormatter object");
+ zend_throw_exception_ex(IntlException_ce_ptr, 0, "Failed to clone MessageFormatter object");
}
} else {
- zend_throw_exception_ex(NULL, 0, "Cannot clone unconstructed MessageFormatter");
+ zend_throw_exception_ex(IntlException_ce_ptr, 0, "Cannot clone unconstructed MessageFormatter");
}
return new_obj;
}
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index b8d27c940a..60800fe1a9 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -74,7 +74,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
/* }}} */
/* {{{ ResourceBundle_ctor */
-static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char *bundlename;
size_t bundlename_len = 0;
@@ -90,8 +90,8 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "resourcebundle_ctor: unable to parse input parameters", 0 );
+ intl_error_set_ex( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "resourcebundle_ctor: unable to parse input parameters", 0, is_constructor );
Z_OBJ_P(return_value) = NULL;
return;
}
@@ -108,7 +108,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
}
- INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
+ INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle", is_constructor);
if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING ||
INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
@@ -119,7 +119,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
bundlename ? bundlename : "(default data)", locale,
ures_getLocaleByType(
rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)));
- intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1);
+ intl_errors_set_custom_msg_ex(INTL_DATA_ERROR_P(rb), pbuf, 1, is_constructor);
efree(pbuf);
Z_OBJ_P(return_value) = NULL;
}
@@ -142,7 +142,7 @@ PHP_METHOD( ResourceBundle, __construct )
zval orig_this = *getThis();
return_value = getThis();
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this));
@@ -157,7 +157,7 @@ proto ResourceBundle resourcebundle_create( string $locale [, string $bundlename
PHP_FUNCTION( resourcebundle_create )
{
object_init_ex( return_value, ResourceBundle_ce_ptr );
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}
diff --git a/ext/intl/spoofchecker/spoofchecker_create.c b/ext/intl/spoofchecker/spoofchecker_create.c
index d797015cf8..b56c840961 100644
--- a/ext/intl/spoofchecker/spoofchecker_create.c
+++ b/ext/intl/spoofchecker/spoofchecker_create.c
@@ -38,7 +38,7 @@ PHP_METHOD(Spoofchecker, __construct)
SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK;
co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
- INTL_CTOR_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
+ INTL_CTOR_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker", 1);
/* Single-script enforcement is on by default. This fails for languages
like Japanese that legally use multiple scripts within a single word,
diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt
index 50aeae4806..e5c216c1e2 100644
--- a/ext/intl/tests/bug62017.phpt
+++ b/ext/intl/tests/bug62017.phpt
@@ -10,13 +10,15 @@ ini_set('intl.error_level', E_WARNING);
var_dump(
datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
IntlDateFormatter::GREGORIAN, 'a'));
-var_dump(
+try {
new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
- IntlDateFormatter::GREGORIAN, "\x80"));
+ IntlDateFormatter::GREGORIAN, "\x80");
+}
+catch(IntlException $ie) {
+ echo $ie->getMessage().PHP_EOL;
+}
--EXPECTF--
Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
NULL
-
-Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d
-NULL
+datefmt_create: error converting pattern to UTF-16
diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt
index 295f011008..c45b113bdb 100644
--- a/ext/intl/tests/formatter_fail.phpt
+++ b/ext/intl/tests/formatter_fail.phpt
@@ -12,16 +12,23 @@ function err($fmt) {
}
function crt($t, $l, $s) {
- switch(true) {
- case $t == "O":
- return new NumberFormatter($l, $s);
- break;
- case $t == "C":
- return NumberFormatter::create($l, $s);
- break;
- case $t == "P":
- return numfmt_create($l, $s);
- break;
+ try {
+ $fmt = null;
+ switch(true) {
+ case $t == "O":
+ $fmt = new NumberFormatter($l, $s);
+ break;
+ case $t == "C":
+ $fmt = NumberFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ $fmt = numfmt_create($l, $s);
+ break;
+ }
+ err($fmt);
+ }
+ catch(IntlException $ie) {
+ echo "IE: ".$ie->getMessage().PHP_EOL;
}
}
@@ -33,8 +40,13 @@ $args = array(
array("en_US", NumberFormatter::PATTERN_RULEBASED),
);
-$fmt = new NumberFormatter();
-err($fmt);
+try {
+ $fmt = new NumberFormatter();
+}
+catch(IntlException $ie) {
+ echo $ie->getMessage().PHP_EOL;
+}
+
$fmt = numfmt_create();
err($fmt);
$fmt = NumberFormatter::create();
@@ -42,11 +54,8 @@ err($fmt);
foreach($args as $arg) {
$fmt = crt("O", $arg[0], $arg[1]);
- err($fmt);
$fmt = crt("C", $arg[0], $arg[1]);
- err($fmt);
$fmt = crt("P", $arg[0], $arg[1]);
- err($fmt);
}
?>
@@ -70,10 +79,10 @@ Warning: NumberFormatter::create() expects parameter 1 to be string, array given
'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
Warning: numfmt_create() expects parameter 1 to be string, array given in %s on line %d
-'numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
-'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
-'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
-'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
-'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
-'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
-'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR'
+IE: numfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR
+IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
+IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
+IE: numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR
+IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
+IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
+IE: numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR
diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt
index 334ef49567..0fa88681d9 100644
--- a/ext/intl/tests/formatter_format.phpt
+++ b/ext/intl/tests/formatter_format.phpt
@@ -50,7 +50,14 @@ function ut_main()
$str_res .= "\nLocale is: $locale\n";
foreach( $styles as $style => $pattern )
{
- $fmt = ut_nfmt_create( $locale, $style, $pattern );
+ try {
+ $fmt = ut_nfmt_create( $locale, $style, $pattern );
+ }
+ catch (IntlException $ie) {
+ //$str_res .= "IE:".$ie->getMessage()."\n";
+ $str_res .= "Bad formatter!\n";
+ continue;
+ }
if(!$fmt) {
$str_res .= "Bad formatter!\n";
diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt
index 45229cf000..a28fa715e4 100644
--- a/ext/intl/tests/gregoriancalendar___construct_error.phpt
+++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt
@@ -11,8 +11,18 @@ ini_set("intl.error_level", E_WARNING);
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7));
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8));
var_dump(intlgregcal_create_instance(1,2,3,4));
-var_dump(new IntlGregorianCalendar(1,2,NULL,4));
-var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
+try {
+ new IntlGregorianCalendar(1,2,NULL,4);
+}
+catch (IntlException $ie) {
+ echo "IE: ".$ie->getMessage().PHP_EOL;
+}
+try {
+ new IntlGregorianCalendar(1,2,3,4,NULL,array());
+}
+catch (IntlException $ie) {
+ echo "IE: ".$ie->getMessage().PHP_EOL;
+}
--EXPECTF--
@@ -26,10 +36,6 @@ NULL
Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
NULL
-Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
-NULL
-
+IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs)
Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be integer, array given in %s on line %d
-
-Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments in %s on line %d
-NULL
+IE: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments
diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt
index bffb71c56d..4b60b35abc 100644
--- a/ext/intl/tests/msgfmt_fail.phpt
+++ b/ext/intl/tests/msgfmt_fail.phpt
@@ -13,16 +13,24 @@ function err($fmt) {
}
function crt($t, $l, $s) {
- switch(true) {
- case $t == "O":
- return new MessageFormatter($l, $s);
- break;
- case $t == "C":
- return MessageFormatter::create($l, $s);
- break;
- case $t == "P":
- return msgfmt_create($l, $s);
- break;
+
+ try {
+ $fmt = null;
+ switch(true) {
+ case $t == "O":
+ $fmt = new MessageFormatter($l, $s);
+ break;
+ case $t == "C":
+ $fmt = MessageFormatter::create($l, $s);
+ break;
+ case $t == "P":
+ $fmt = msgfmt_create($l, $s);
+ break;
+ }
+ err($fmt);
+ }
+ catch (IntlException $ie) {
+ echo "IE: ".$ie->getMessage().PHP_EOL;
}
}
@@ -35,32 +43,36 @@ $args = array(
array("en_US", "\xD0"),
);
-$fmt = new MessageFormatter();
-err($fmt);
+try {
+ $fmt = new MessageFormatter();
+}
+catch(IntlException $ie) {
+ echo "IE: ".$ie->getMessage().PHP_EOL;
+}
$fmt = msgfmt_create();
err($fmt);
$fmt = MessageFormatter::create();
-err($fmt);
-$fmt = new MessageFormatter('en');
-err($fmt);
+err($fmt);
+try {
+ $fmt = new MessageFormatter('en');
+}
+catch(IntlException $ie) {
+ echo "IE: ".$ie->getMessage().PHP_EOL;
+}
$fmt = msgfmt_create('en');
err($fmt);
$fmt = MessageFormatter::create('en');
err($fmt);
foreach($args as $arg) {
- $fmt = crt("O", $arg[0], $arg[1]);
- err($fmt);
- $fmt = crt("C", $arg[0], $arg[1]);
- err($fmt);
- $fmt = crt("P", $arg[0], $arg[1]);
- err($fmt);
+ crt("O", $arg[0], $arg[1]);
+ crt("C", $arg[0], $arg[1]);
+ crt("P", $arg[0], $arg[1]);
}
?>
--EXPECTF--
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 0 given in %s on line %d
-'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+IE: msgfmt_create: unable to parse input parameters
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'
@@ -68,8 +80,7 @@ Warning: msgfmt_create() expects exactly 2 parameters, 0 given in %s on line %d
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'
-Warning: MessageFormatter::__construct() expects exactly 2 parameters, 1 given in %s on line %d
-'msgfmt_create: unable to parse input parameters: U_ILLEGAL_ARGUMENT_ERROR'
+IE: msgfmt_create: unable to parse input parameters
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'
diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt
index b9ec36374b..2eaf630010 100644
--- a/ext/intl/tests/msgfmt_parse.phpt
+++ b/ext/intl/tests/msgfmt_parse.phpt
@@ -36,9 +36,15 @@ function ut_main()
foreach( $locales as $locale => $pattern )
{
$str_res .= "\nLocale is: $locale\n";
- $fmt = ut_msgfmt_create( $locale, $pattern );
- if(!$fmt) {
- $str_res .= dump(intl_get_error_message())."\n";
+ try {
+ $fmt = ut_msgfmt_create( $locale, $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
+ continue;
+ }
+ }
+ catch (\IntlException $ie) {
+ $str_res .= "IE: ".$ie->getMessage().PHP_EOL;
continue;
}
$str_res .= dump( ut_msgfmt_parse( $fmt, $results[$locale] ) ) . "\n";
@@ -103,7 +109,7 @@ array (
)
Locale is: root
-'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
+IE: msgfmt_create: message formatter creation failed
Locale is: fr
array (
diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt
index 2bf4f556a8..99492a698b 100644
--- a/ext/intl/tests/resourcebundle_create.phpt
+++ b/ext/intl/tests/resourcebundle_create.phpt
@@ -14,6 +14,7 @@ function ut_main() {
$str_res .= debug( $r1 );
$str_res .= print_r( $r1['teststring'], true)."\n";
+
// non-root one
$r1 = ut_resourcebundle_create( 'es', BUNDLE );
$str_res .= debug( $r1 );
@@ -24,14 +25,22 @@ function ut_main() {
$str_res .= debug( $r1 );
$str_res .= print_r( $r1['testsring'], true);
- // fall out
- $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
- $str_res .= debug( $r2 );
+ try {
+ // fall out
+ $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false );
+ }
+ catch (\IntlException $ie) {
+ $str_res .= "ie: ".$ie->getMessage().PHP_EOL;
+ }
+
+ try {
+ // missing
+ $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
+ }
+ catch (\IntlException $ie) {
+ $str_res .= "ie: ".$ie->getMessage().PHP_EOL;
+ }
- // missing
- $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' );
- $str_res .= debug( $r3 );
-
return $str_res;
}
@@ -56,7 +65,5 @@ ResourceBundle Object
)
-127: U_USING_DEFAULT_WARNING
-NULL
- 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
-NULL
- 2: resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR
+ie: resourcebundle_ctor: Cannot load libICU resource bundle
+ie: resourcebundle_ctor: Cannot load libICU resource bundle
diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c
index d8b030a6d1..7be1412b13 100644
--- a/ext/intl/transliterator/transliterator_methods.c
+++ b/ext/intl/transliterator/transliterator_methods.c
@@ -169,7 +169,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
str_rules, str_rules_len, TRANSLITERATOR_ERROR_CODE_P( to ) );
/* (I'm not a big fan of non-obvious flow control macros ).
* This one checks the error value, destroys object and returns false */
- INTL_CTOR_CHECK_STATUS( to, "String conversion of rules to UTF-16 failed" );
+ INTL_CTOR_CHECK_STATUS( to, "String conversion of rules to UTF-16 failed", 0 );
/* Open ICU Transliterator. */
utrans = utrans_openU( id, ( sizeof( id ) - 1 ) / ( sizeof( *id ) ), (UTransDirection ) direction,
@@ -197,7 +197,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
}
transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
/* no need to close the transliterator manually on construction error */
- INTL_CTOR_CHECK_STATUS( to, "transliterator_create_from_rules: internal constructor call failed" );
+ INTL_CTOR_CHECK_STATUS( to, "transliterator_create_from_rules: internal constructor call failed", 0 );
}
/* }}} */
@@ -228,10 +228,10 @@ PHP_FUNCTION( transliterator_create_inverse )
utrans = utrans_openInverse( to_orig->utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
INTL_CTOR_CHECK_STATUS( to, "transliterator_create_inverse: could not create "
- "inverse ICU transliterator" );
+ "inverse ICU transliterator", 0 );
transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) );
/* no need to close the transliterator manually on construction error */
- INTL_CTOR_CHECK_STATUS( to, "transliterator_create: internal constructor call failed" );
+ INTL_CTOR_CHECK_STATUS( to, "transliterator_create: internal constructor call failed", 0 );
}
/* }}} */