It looks like a bug in the Languages Gallery form (Sitecore.Shell.Applications.ContentManager.Galleries.Languages.GalleryLanguagesForm
). The following code in the OnLoad
method is expected to skip rendering languages if a user hasn't got Read access rights granted.
foreach (Language language in languages)
{
Item languageItem = LanguageManager.GetLanguageItem(language, item.Database);
// this is ALLWAYS null if a user hasn't got Read access
if (languageItem != null)
{
if (!languageItem.Access.CanRead())
{
continue;
}
...
Problem
The problem is in the if (languageItem != null)
statement which is expected to be true
to skip a language, but in fact it's always false
because the user hasn't got the read access and cannot read the language item.
Workaround
You may try override the entire form code-behind class and skip languages if there are no corresponding language items found:
foreach (Language language in languages)
{
Item languageItem = LanguageManager.GetLanguageItem(language, item.Database);
// do not render language if it cannot be read
if (languageItem == null)
{
continue;
}
if (!languageItem.Access.CanRead())
{
continue;
}
The side effect of that is that all the languages from the core
database that have not been duplicated in master
will disappear. That's happening because in the code above the LanguageManager
tries to read and check availability for languages from the item.Database
only (which is master
):
LanguageManager.GetLanguageItem(language, item.Database);