diff --git a/NEWS b/NEWS index 447d052e21dc..88b79668d15c 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,8 @@ PHP NEWS string. (Weilin Du) . Fixed IntlListFormatter::__construct() leaving stale global error state after successful calls. (Weilin Du) + . Fixed IntlNumberRangeFormatter leaving stale global error state after + successful createFromSkeleton() and format() calls. (Weilin Du) . Implemented GH-20255 (Add a predefined calendar constant in IntlDateFormatter for the proleptic gregorian calendar). (David Carlier) . Added SpoofChecker::areBidiConfusable(). (David Carlier) diff --git a/ext/intl/rangeformatter/rangeformatter_class.cpp b/ext/intl/rangeformatter/rangeformatter_class.cpp index 2dbb60c5b639..95acfccd2452 100644 --- a/ext/intl/rangeformatter/rangeformatter_class.cpp +++ b/ext/intl/rangeformatter/rangeformatter_class.cpp @@ -88,6 +88,8 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton) zend_long collapse; zend_long identityFallback; + intl_error_reset(NULL); + ZEND_PARSE_PARAMETERS_START(4,4) Z_PARAM_STRING(skeleton, skeleton_len) Z_PARAM_STRING(locale, locale_len) @@ -158,7 +160,10 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format) zval *start; zval *end; + intl_error_reset(NULL); + IntlNumberRangeFormatter_object* obj = Z_INTL_RANGEFORMATTER_P(ZEND_THIS); + intl_error_reset(RANGEFORMATTER_ERROR_P(obj)); ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_NUMBER(start) @@ -179,13 +184,13 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format) INTL_G(error_level) = 0; if (U_FAILURE(error)) { - intl_error_set(NULL, error, "Failed to format number range"); + intl_errors_set(RANGEFORMATTER_ERROR_P(obj), error, "Failed to format number range"); } zend_string *ret = intl_charFromString(result, &error); if (U_FAILURE(error)) { - intl_error_set(NULL, error, "Failed to convert result to UTF-8"); + intl_errors_set(RANGEFORMATTER_ERROR_P(obj), error, "Failed to convert result to UTF-8"); } INTL_G(use_exceptions) = old_use_exception; diff --git a/ext/intl/tests/rangeformatter/rangeformatter_create_error_reset.phpt b/ext/intl/tests/rangeformatter/rangeformatter_create_error_reset.phpt new file mode 100644 index 000000000000..fb19da87d58d --- /dev/null +++ b/ext/intl/tests/rangeformatter/rangeformatter_create_error_reset.phpt @@ -0,0 +1,54 @@ +--TEST-- +IntlNumberRangeFormatter resets stale errors +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +format(1, 2); + +var_dump(intl_get_error_code()); +var_dump(intl_get_error_message()); +?> +--EXPECT-- +bool(true) +int(0) +string(12) "U_ZERO_ERROR" +int(0) +string(12) "U_ZERO_ERROR"