Commit 42cc4adb1b1 for php.net

commit 42cc4adb1b1f82e6a1c970803ca00d14de931cce
Author: Weilin Du <weilindu@php.net>
Date:   Sun Jun 7 16:48:42 2026 +0800

    ext/intl: Fix ResourceBundle fallback-disabled error message (#22236)

    Fix the typo in ResourceBundle fallback-disabled error message

diff --git a/NEWS b/NEWS
index b96b12eda1b..79536c0ce21 100644
--- a/NEWS
+++ b/NEWS
@@ -65,6 +65,8 @@ PHP                                                                        NEWS
   . Upgrade xxHash to 0.8.2. (timwolla)

 - Intl:
+  . Fixed malformed ResourceBundle::get() error message when fallback is
+    disabled. (Weilin Du)
   . Added IntlNumberRangeFormatter class to format an interval of two numbers
     with a given skeleton, locale, collapse type and identity fallback.
     (BogdanUngureanu)
diff --git a/UPGRADING b/UPGRADING
index 679fc0b552d..2ec6ce92aa5 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -47,6 +47,9 @@ PHP 8.6 UPGRADE NOTES
   . UConverter::transcode() now rejects from_subst and to_subst option values
     longer than 127 bytes instead of silently truncating the length before
     passing it to ICU.
+  . ResourceBundle::get() and resourcebundle_get() now report fallback-disabled
+    resource lookups with "without fallback to <locale>" instead of the
+    malformed "without fallback from to <locale>".

 - PCNTL:
   . pcntl_alarm() now raises a ValueError if the seconds argument is
diff --git a/ext/intl/resourcebundle/resourcebundle_class.cpp b/ext/intl/resourcebundle/resourcebundle_class.cpp
index 43823137e60..2a89b14cc6e 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.cpp
+++ b/ext/intl/resourcebundle/resourcebundle_class.cpp
@@ -220,12 +220,12 @@ static zval *resource_bundle_array_fetch(
 	}

 	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
-		UErrorCode icuerror;
+		UErrorCode icuerror = U_ZERO_ERROR;
 		const char * locale = ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &icuerror );
 		if (is_numeric) {
-			spprintf(&pbuf, 0, "Cannot load element %d without fallback from to %s", index, locale);
+			spprintf(&pbuf, 0, "Cannot load element %d without fallback to %s", index, locale);
 		} else {
-			spprintf(&pbuf, 0, "Cannot load element '%s' without fallback from to %s", key, locale);
+			spprintf(&pbuf, 0, "Cannot load element '%s' without fallback to %s", key, locale);
 		}
 		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf);
 		efree(pbuf);
diff --git a/ext/intl/tests/resourcebundle_get_without_fallback.phpt b/ext/intl/tests/resourcebundle_get_without_fallback.phpt
new file mode 100644
index 00000000000..9f994122797
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_get_without_fallback.phpt
@@ -0,0 +1,48 @@
+--TEST--
+ResourceBundle::get() rejects fallback results when fallback is disabled with correct error message
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+require_once "resourcebundle.inc";
+
+$fixture = __DIR__ . '/resourcebundle_get_without_fallback_tmp';
+if (!is_dir($fixture)) {
+    mkdir($fixture);
+}
+copy(BUNDLE . '/root.res', $fixture . '/root.res');
+
+$resIndex = file_get_contents(BUNDLE . '/res_index.res');
+$resIndex = str_replace("\0es\0root", "\0en\0root", $resIndex, $replacementCount);
+if ($replacementCount !== 1) {
+    die("Failed to prepare resource bundle index\n");
+}
+file_put_contents($fixture . '/res_index.res', $resIndex);
+
+// Keep the binary layout intact while making this key fall back to root.res.
+$enBundle = file_get_contents(BUNDLE . '/es.res');
+$enBundle = str_replace('teststring', 'teststrinh', $enBundle, $replacementCount);
+if ($replacementCount !== 1) {
+    die("Failed to prepare resource bundle fixture\n");
+}
+file_put_contents($fixture . '/en.res', $enBundle);
+
+$bundle = new ResourceBundle('en', $fixture);
+echo debug($bundle->get('teststring', false));
+
+$bundle = resourcebundle_create('en', $fixture);
+echo debug(resourcebundle_get($bundle, 'teststring', false));
+?>
+--EXPECTF--
+NULL
+ %i: ResourceBundle::get(): Cannot load element 'teststring' without fallback to %s: U_USING_%s_WARNING
+NULL
+ %i: resourcebundle_get(): Cannot load element 'teststring' without fallback to %s: U_USING_%s_WARNING
+--CLEAN--
+<?php
+$fixture = __DIR__ . '/resourcebundle_get_without_fallback_tmp';
+@unlink($fixture . '/en.res');
+@unlink($fixture . '/root.res');
+@unlink($fixture . '/res_index.res');
+@rmdir($fixture);
+?>