Commit 5645e5b0803 for php

commit 5645e5b0803e4e3bd5a5e98d199fe79acd45228f
Author: Weilin Du <weilindu@php.net>
Date:   Sun Nov 15 03:25:05 2026 +0000

    ext/intl: Fix Locale::lookup() fallback for empty language tags (#25462)

    Return the supplied default locale when the language tag list is empty.
    Locale::lookup([], 'fr_FR', false, 'en_US') now returns 'en_US' instead
    of an empty string.

    Closes #25462

diff --git a/NEWS b/NEWS
index 84e8fdd0473..5fde6a46c6b 100644
--- a/NEWS
+++ b/NEWS
@@ -174,6 +174,8 @@ PHP                                                                        NEWS
 - Intl:
   . Fixed IntlDateFormatter parse functions truncating an $offset below
     INT_MIN. (Marc Bennewitz)
+  . Fixed Locale::lookup() ignoring the default locale when the language tag
+    list is empty. (Weilin Du)

 - JSON:
   . Fixed json_decode() and json_validate() error messages. (lacatoire)
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index 2643f492087..1b61794d67f 100644
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -1560,6 +1560,9 @@ PHP_FUNCTION(locale_lookup)
 	INTL_CHECK_LOCALE_LEN(loc_range_len);

 	if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ) {
+		if (fallback_loc_str) {
+			RETURN_STR_COPY(fallback_loc_str);
+		}
 		RETURN_EMPTY_STRING();
 	}

diff --git a/ext/intl/tests/locale_lookup_empty_language_tags.phpt b/ext/intl/tests/locale_lookup_empty_language_tags.phpt
new file mode 100644
index 00000000000..b0bb2d1e699
--- /dev/null
+++ b/ext/intl/tests/locale_lookup_empty_language_tags.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Locale::lookup() honors the default locale for an empty language tag list
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+foreach (['locale_lookup', [Locale::class, 'lookup']] as $lookup) {
+    foreach ([false, true] as $canonicalize) {
+        var_dump($lookup([], 'fr_FR', $canonicalize, 'en-US'));
+        var_dump($lookup([], '', $canonicalize, 'en-US'));
+        var_dump($lookup([], 'fr_FR', $canonicalize, ''));
+        var_dump($lookup([], 'fr_FR', $canonicalize, null));
+        var_dump($lookup([], 'fr_FR', $canonicalize));
+        var_dump(intl_get_error_code());
+    }
+}
+?>
+--EXPECT--
+string(5) "en-US"
+string(5) "en-US"
+string(0) ""
+string(0) ""
+string(0) ""
+int(0)
+string(5) "en-US"
+string(5) "en-US"
+string(0) ""
+string(0) ""
+string(0) ""
+int(0)
+string(5) "en-US"
+string(5) "en-US"
+string(0) ""
+string(0) ""
+string(0) ""
+int(0)
+string(5) "en-US"
+string(5) "en-US"
+string(0) ""
+string(0) ""
+string(0) ""
+int(0)