diff --git a/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs index 4027184f3c..0810f2207b 100644 --- a/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/ILivePublishedModelFactory.cs @@ -13,6 +13,10 @@ /// /// Refreshes the factory. /// + /// + /// This will typically re-compiled models/classes into a new DLL that are used to populate the cache. + /// This is called prior to refreshing the cache. + /// void Refresh(); } } diff --git a/src/Umbraco.Core/PublishedModelFactoryExtensions.cs b/src/Umbraco.Core/PublishedModelFactoryExtensions.cs index 4e026490a4..d428accbbf 100644 --- a/src/Umbraco.Core/PublishedModelFactoryExtensions.cs +++ b/src/Umbraco.Core/PublishedModelFactoryExtensions.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core public static class PublishedModelFactoryExtensions { /// - /// Executes an action with a safe live factory/ + /// Executes an action with a safe live factory /// /// /// If the factory is a live factory, ensures it is refreshed and locked while executing the action. @@ -20,6 +20,7 @@ namespace Umbraco.Core { lock (liveFactory.SyncRoot) { + //Call refresh on the live factory to re-compile the models liveFactory.Refresh(); action(); } diff --git a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs index a5134426c2..75f2889cab 100644 --- a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs @@ -53,15 +53,15 @@ namespace Umbraco.Web.Cache _contentTypeCommonRepository.ClearCache(); // always - // We need to special handle the IContentType if modelsbuilder is in live mode, because all models are updated when a IContentType is changed, we need to clear all from cache also. - if (_publishedModelFactory is ILivePublishedModelFactory && payloads.Any(x => x.ItemType == typeof(IContentType).Name)) - { - //This is super nasty, and we need to figure out a better way to to this - //Ensure all doc type ids is part of the payload - var missingPayloads = GetMissingContentTypePayloads(payloads); + //// We need to special handle the IContentType if modelsbuilder is in live mode, because all models are updated when a IContentType is changed, we need to clear all from cache also. + //if (_publishedModelFactory is ILivePublishedModelFactory && payloads.Any(x => x.ItemType == typeof(IContentType).Name)) + //{ + // //This is super nasty, and we need to figure out a better way to to this + // //Ensure all doc type ids is part of the payload + // var missingPayloads = GetMissingContentTypePayloads(payloads); - payloads = payloads.Union(missingPayloads).ToArray(); - } + // payloads = payloads.Union(missingPayloads).ToArray(); + //} if (payloads.Any(x => x.ItemType == typeof(IContentType).Name)) { @@ -109,19 +109,19 @@ namespace Umbraco.Web.Cache base.Refresh(payloads); } - private IEnumerable GetMissingContentTypePayloads(JsonPayload[] payloads) - { - var existingPayloadIds = new HashSet(payloads.Select(x => x.Id)); - var contentTypeIds = _contentTypeService.GetAll().Select(x => x.Id).ToArray(); + //private IEnumerable GetMissingContentTypePayloads(JsonPayload[] payloads) + //{ + // var existingPayloadIds = new HashSet(payloads.Select(x => x.Id)); + // var contentTypeIds = _contentTypeService.GetAll().Select(x => x.Id).ToArray(); - foreach (var contentTypeId in contentTypeIds) - { - if (!existingPayloadIds.Contains(contentTypeId)) - { - yield return new JsonPayload(typeof(IContentType).Name, contentTypeId, ContentTypeChangeTypes.RefreshOther); - } - } - } + // foreach (var contentTypeId in contentTypeIds) + // { + // if (!existingPayloadIds.Contains(contentTypeId)) + // { + // yield return new JsonPayload(typeof(IContentType).Name, contentTypeId, ContentTypeChangeTypes.RefreshOther); + // } + // } + //} public override void RefreshAll() {