[php-src] master: Merge branch 'PHP-8.5'
| From: | Ilia Alshanetsky | Date: | Sun, 13 Sep 2026 14:39:40 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141186@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-13T10:35:41-04:00
Commit: https://github.com/php/php-src/commit/9a06a29513dc34738a7e7dc1329ae7dc059f9246
Raw diff: https://github.com/php/php-src/commit/9a06a29513dc34738a7e7dc1329ae7dc059f9246.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
ext/intl: Resolve UConverter callbacks when the object is allocated
Changed paths:
A ext/intl/tests/uconverter_clone_callback.phpt
M NEWS
M ext/intl/converter/converter.cpp
Diff:
diff --git a/NEWS b/NEWS
index c7f2bb053952..0dd04e091cda 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ PHP NEWS
. Fixed cloning IntlDateFormatter and MessageFormatter losing PHP-side state
such as dateType, timeType, calendar and the message pattern.
(Ilia Alshanetsky)
+ . Fixed a crash when converting with a cloned UConverter that uses
+ toUCallback/fromUCallback. (Ilia Alshanetsky)
- MBString:
. Fixed bug GH-23106 (mb_strpos() reads past the end of a haystack ending in
diff --git a/ext/intl/converter/converter.cpp b/ext/intl/converter/converter.cpp
index c2f543f2c4ab..1369b88742f4 100644
--- a/ext/intl/converter/converter.cpp
+++ b/ext/intl/converter/converter.cpp
@@ -547,8 +547,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;
@@ -927,6 +925,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;
diff --git a/ext/intl/tests/uconverter_clone_callback.phpt
b/ext/intl/tests/uconverter_clone_callback.phpt
new file mode 100644
index 000000000000..140841b455e5
--- /dev/null
+++ b/ext/intl/tests/uconverter_clone_callback.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Cloned UConverter resolves toUCallback/fromUCallback on the clone
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+
+class MyConverter extends UConverter {
+ public int $hits = 0;
+
+ public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
+ $this->hits++;
+ return parent::toUCallback($reason, $source, $codeUnits, $error);
+ }
+}
+
+$orig = new MyConverter('ascii', 'utf-8');
+$clone = clone $orig;
+$clone->convert("irregul\xC1\xA1r");
+echo $clone->hits > 0 ? "ok\n" : "no callback\n";
+
+?>
+--EXPECT--
+ok