Skip to content

ext/intl: Fix stale intl error state in IntlNumberRangeFormatter - #23191

Open
LamentXU123 wants to merge 3 commits into
php:masterfrom
LamentXU123:intl-bugfix
Open

ext/intl: Fix stale intl error state in IntlNumberRangeFormatter#23191
LamentXU123 wants to merge 3 commits into
php:masterfrom
LamentXU123:intl-bugfix

Conversation

@LamentXU123

@LamentXU123 LamentXU123 commented Aug 9, 2026

Copy link
Copy Markdown
Member

IntlNumberRangeFormatter::createFromSkeleton() and IntlNumberRangeFormatter::format() did not reset intl error state

I know this is yet another "error state" fixes. Unfortunately we couldn't use the function macro added before because these are methods, and we can only reset the error state manually so far.

I personally hate the error state design. I think we should throw exceptions instead. But considering BC breaks... this is just an idea in the void.

IntlNumberRangeFormatter is added in 8.6 so this is the correct branch.

intl_error_reset(NULL);

IntlNumberRangeFormatter_object* obj = Z_INTL_RANGEFORMATTER_P(ZEND_THIS);
intl_error_reset(RANGEFORMATTER_ERROR_P(obj));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reset is a no-op: every failure path calls intl_error_set(NULL, ...),
which only writes the global error, so the object slot is never set.
Switch the two calls in format() to
intl_errors_set(RANGEFORMATTER_ERROR_P(obj), ...), then getErrorCode()
stops always returning U_ZERO_ERROR.

@devnexen

devnexen commented Aug 9, 2026

Copy link
Copy Markdown
Member

ok otherwise..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants