Skip to content

Resolve UConverter callbacks after clone - #23324

Open
iliaal wants to merge 1 commit into
php:PHP-8.5from
iliaal:fix/intl-uconverter-clone-callback
Open

Resolve UConverter callbacks after clone#23324
iliaal wants to merge 1 commit into
php:PHP-8.5from
iliaal:fix/intl-uconverter-clone-callback

Conversation

@iliaal

@iliaal iliaal commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

UConverter::__construct() fills to_cache/from_cache. clone only retargeted the ICU C callbacks and left those FCCs zeroed, so the first callback-worthy convert called zend_call_known_fcc on a NULL handler. Resolve both caches on the clone.

__construct fills to_cache/from_cache via php_converter_resolve_callback.
clone only retargeted the ICU C callbacks, leaving the FCC zeroed, so
the first callback-worthy convert called zend_call_known_fcc on a NULL
handler. Resolve both caches on the clone.

zend_objects_clone_members(&(objval->obj), &(oldobj->obj));

php_converter_resolve_callback(&objval->to_cache, &objval->obj, ZEND_STRL("toUCallback"));

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.

--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -546,8 +546,6 @@ PHP_METHOD(UConverter, __construct) {
              ZEND_ASSERT(EG(exception));
              goto cleanup;
      }
-     php_converter_resolve_callback(&objval->to_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("toUCallback"));
-     php_converter_resolve_callback(&objval->from_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("fromUCallback"));
 cleanup:
      INTL_G(use_exceptions) = old_use_exception;
      INTL_G(error_level) = old_error_level;
@@ -916,6 +914,8 @@ static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converte
      zend_object_std_init(&objval->obj, ce);
      object_properties_init(&objval->obj, ce);
      intl_error_init(&(objval->error));
+     php_converter_resolve_callback(&objval->to_cache, &objval->obj, ZEND_STRL("toUCallback"));
+     php_converter_resolve_callback(&objval->from_cache, &objval->obj, ZEND_STRL("fromUCallback"));

      *pobjval = objval;

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