Skip to content

Commit 11b4217

Browse files
Merge branch '4.4' into 5.2
* 4.4: Stop using deprecated ArrayCache from Doctrine [Intl] fix Locale::getFallback() throwing exception on long $locale
2 parents 7227bec + fe19caf commit 11b4217

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Locale.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public static function getDefaultFallback(): ?string
6666
public static function getFallback(string $locale): ?string
6767
{
6868
if (\function_exists('locale_parse')) {
69-
$localeSubTags = locale_parse($locale);
69+
$localeSubTags = locale_parse($locale) ?? ['language' => $locale];
70+
7071
if (1 === \count($localeSubTags)) {
7172
if ('root' !== self::$defaultFallback && self::$defaultFallback === $localeSubTags['language']) {
7273
return 'root';

Tests/LocaleTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,16 @@ public function testDefaultRootFallback()
7070

7171
Locale::setDefaultFallback($prev);
7272
}
73+
74+
/**
75+
* @requires function locale_parse
76+
*/
77+
public function testLongLocaleFallback()
78+
{
79+
$locale = 'LC_TYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;'.
80+
'LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=fr_FR.UTF-8;'.
81+
'LC_ADDRESS=fr_FR.UTF-8;LC_TELEPHONE=fr_FR.UTF-8;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=fr_FR.UTF-8';
82+
83+
$this->assertNull(Locale::getFallback($locale));
84+
}
7385
}

0 commit comments

Comments
 (0)