Merge pull request #13732 from annando/issue-13731

Issue 13731: Fix error concerning invalid user
This commit is contained in:
Hypolite Petovan 2023-12-17 21:16:28 -05:00 committed by GitHub
commit 47b0302811
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -567,10 +567,12 @@ class User
*/ */
public static function getLanguageCode(int $uid): string public static function getLanguageCode(int $uid): string
{ {
$owner = self::getOwnerDataById($uid); $owner = self::getOwnerDataById($uid);
$language = DI::l10n()->toISO6391($owner['language']); if (!empty($owner['language'])) {
if (in_array($language, array_keys(DI::l10n()->getLanguageCodes()))) { $language = DI::l10n()->toISO6391($owner['language']);
return $language; if (in_array($language, array_keys(DI::l10n()->getLanguageCodes()))) {
return $language;
}
} }
return DI::l10n()->toISO6391(DI::config()->get('system', 'language')); return DI::l10n()->toISO6391(DI::config()->get('system', 'language'));
} }