From f2b7e27b34044a6219f4f2a856233b1d7fc80f58 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2014 11:30:02 +1100 Subject: [PATCH] Fixes: U4-2721 RuntimeCacheProvider is not cleared when data type changes and updates the repo factory to not use the InMemory cache provider since we should only ever use that for very very specific reasons since the memory can never auto-clear with that provider. --- src/Umbraco.Core/Persistence/RepositoryFactory.cs | 10 +++++----- src/Umbraco.Core/Services/IUserService.cs | 4 +++- src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs | 11 +++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Persistence/RepositoryFactory.cs b/src/Umbraco.Core/Persistence/RepositoryFactory.cs index 6b9299a0cf..4d67838ffd 100644 --- a/src/Umbraco.Core/Persistence/RepositoryFactory.cs +++ b/src/Umbraco.Core/Persistence/RepositoryFactory.cs @@ -54,7 +54,7 @@ namespace Umbraco.Core.Persistence { return new ContentTypeRepository( uow, - _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current, + _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current, new TemplateRepository(uow, NullCacheProvider.Current)); } @@ -69,7 +69,7 @@ namespace Umbraco.Core.Persistence { return new DictionaryRepository( uow, - _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current, + _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current, CreateLanguageRepository(uow)); } @@ -77,7 +77,7 @@ namespace Umbraco.Core.Persistence { return new LanguageRepository( uow, - _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current); + _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current); } public virtual IMediaRepository CreateMediaRepository(IDatabaseUnitOfWork uow) @@ -92,7 +92,7 @@ namespace Umbraco.Core.Persistence { return new MediaTypeRepository( uow, - _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current); + _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current); } public virtual IRelationRepository CreateRelationRepository(IDatabaseUnitOfWork uow) @@ -157,7 +157,7 @@ namespace Umbraco.Core.Persistence internal virtual IMemberTypeRepository CreateMemberTypeRepository(IDatabaseUnitOfWork uow) { - return new MemberTypeRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : InMemoryCacheProvider.Current); + return new MemberTypeRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current); } internal virtual IEntityRepository CreateEntityRepository(IDatabaseUnitOfWork uow) diff --git a/src/Umbraco.Core/Services/IUserService.cs b/src/Umbraco.Core/Services/IUserService.cs index 3c40d9d175..644326a1d4 100644 --- a/src/Umbraco.Core/Services/IUserService.cs +++ b/src/Umbraco.Core/Services/IUserService.cs @@ -47,7 +47,9 @@ namespace Umbraco.Core.Services /// Get permissions set for user and specified node ids /// /// - /// + /// + /// Specifiying nothing will return all user permissions for all nodes + /// /// IEnumerable GetPermissions(IUser user, params int[] nodeIds); diff --git a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs index 7691c1a125..f8c6de39cc 100644 --- a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs @@ -5,6 +5,7 @@ using Umbraco.Core.Cache; using System.Linq; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.Persistence.Caching; namespace Umbraco.Web.Cache { @@ -115,6 +116,16 @@ namespace Umbraco.Web.Cache { var payloads = DeserializeFromJsonPayload(jsonPayload); + //we need to clear the ContentType runtime cache since that is what caches the + // db data type to store the value against and anytime a datatype changes, this also might change + // we basically need to clear all sorts of runtime caches here because so many things depend upon a data type + RuntimeCacheProvider.Current.Clear(typeof(IContent)); + RuntimeCacheProvider.Current.Clear(typeof (IContentType)); + RuntimeCacheProvider.Current.Clear(typeof(IMedia)); + RuntimeCacheProvider.Current.Clear(typeof(IMediaType)); + RuntimeCacheProvider.Current.Clear(typeof(IMember)); + RuntimeCacheProvider.Current.Clear(typeof(IMemberType)); + payloads.ForEach(payload => { //clear both the Id and Unique Id cache since we cache both in the legacy classes :(