ensures the domain cache is totally refreshed when changing langs

This commit is contained in:
Shannon
2019-10-14 22:02:42 +11:00
parent ae0ad2b897
commit 9008641965
3 changed files with 44 additions and 39 deletions

View File

@@ -235,6 +235,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
ContentTypeService.ScopedRefreshedEntity += OnContentTypeRefreshedEntity;
MediaTypeService.ScopedRefreshedEntity += OnMediaTypeRefreshedEntity;
MemberTypeService.ScopedRefreshedEntity += OnMemberTypeRefreshedEntity;
LocalizationService.SavedLanguage += OnLanguageSaved;
}
private void TearDownRepositoryEvents()
@@ -252,6 +254,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
ContentTypeService.ScopedRefreshedEntity -= OnContentTypeRefreshedEntity;
MediaTypeService.ScopedRefreshedEntity -= OnMediaTypeRefreshedEntity;
MemberTypeService.ScopedRefreshedEntity -= OnMemberTypeRefreshedEntity;
LocalizationService.SavedLanguage -= OnLanguageSaved;
}
public override void Dispose()
@@ -1260,6 +1264,20 @@ namespace Umbraco.Web.PublishedCache.NuCache
RebuildMemberDbCache(contentTypeIds: memberTypeIds);
}
/// <summary>
/// If a <see cref="ILanguage"/> is ever saved with a different culture, we need to rebuild all of the content nucache table
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnLanguageSaved(ILocalizationService sender, Core.Events.SaveEventArgs<ILanguage> e)
{
var cultureChanged = e.SavedEntities.Any(x => x.WasPropertyDirty(nameof(ILanguage.IsoCode)));
if(cultureChanged)
{
RebuildContentDbCache();
}
}
private ContentNuDto GetDto(IContentBase content, bool published)
{
// should inject these in ctor