Skip to content

ext/intl: Refactor global error resets - #22990

Draft
LamentXU123 wants to merge 2 commits into
php:masterfrom
LamentXU123:intl-error-code
Draft

ext/intl: Refactor global error resets#22990
LamentXU123 wants to merge 2 commits into
php:masterfrom
LamentXU123:intl-error-code

Conversation

@LamentXU123

@LamentXU123 LamentXU123 commented Aug 1, 2026

Copy link
Copy Markdown
Member

Given the intl code base is using intl_error_reset(NULL); in the start of every PHP_FUNCTION to reset the error state. I'd suggest to add something like

  #define PHP_INTL_FUNCTION_WITH_ERROR_RESET(name) \
        static void php_intl_##name##_impl(INTERNAL_FUNCTION_PARAMETERS); \
        U_CFUNC PHP_FUNCTION(name) \
        { \
                intl_error_reset(NULL); \
                php_intl_##name##_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU); \
        } \
        static void php_intl_##name##_impl(INTERNAL_FUNCTION_PARAMETERS)

So we can directly use the PHP_INTL_FUNCTION_WITH_ERROR_RESET macro to automatically reset error state in the start of every userland function.
I am working on this idea but this should be a massive refactor. Because I found so many cases that we forgot to reset error state in the start of php_functions that cause bugs. e.g.: #22931 #22500 and it is really annoying to add a line to reset the state in every function.

Some PHP_FUNCTION do the error state reset in internal helper function calls. Those are not affected.

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.

1 participant