comments out the fix during investigation - adds some notes

This commit is contained in:
Shannon
2019-07-03 15:17:51 +10:00
parent 47cdc79fcb
commit cd6ef35bf9
3 changed files with 26 additions and 21 deletions

View File

@@ -13,6 +13,10 @@
/// <summary> /// <summary>
/// Refreshes the factory. /// Refreshes the factory.
/// </summary> /// </summary>
/// <remarks>
/// <para>This will typically re-compiled models/classes into a new DLL that are used to populate the cache.</para>
/// <para>This is called prior to refreshing the cache.</para>
/// </remarks>
void Refresh(); void Refresh();
} }
} }

View File

@@ -9,7 +9,7 @@ namespace Umbraco.Core
public static class PublishedModelFactoryExtensions public static class PublishedModelFactoryExtensions
{ {
/// <summary> /// <summary>
/// Executes an action with a safe live factory/ /// Executes an action with a safe live factory
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para>If the factory is a live factory, ensures it is refreshed and locked while executing the action.</para> /// <para>If the factory is a live factory, ensures it is refreshed and locked while executing the action.</para>
@@ -20,6 +20,7 @@ namespace Umbraco.Core
{ {
lock (liveFactory.SyncRoot) lock (liveFactory.SyncRoot)
{ {
//Call refresh on the live factory to re-compile the models
liveFactory.Refresh(); liveFactory.Refresh();
action(); action();
} }

View File

@@ -53,15 +53,15 @@ namespace Umbraco.Web.Cache
_contentTypeCommonRepository.ClearCache(); // always _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. //// 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)) //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 // //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 // //Ensure all doc type ids is part of the payload
var missingPayloads = GetMissingContentTypePayloads(payloads); // var missingPayloads = GetMissingContentTypePayloads(payloads);
payloads = payloads.Union(missingPayloads).ToArray(); // payloads = payloads.Union(missingPayloads).ToArray();
} //}
if (payloads.Any(x => x.ItemType == typeof(IContentType).Name)) if (payloads.Any(x => x.ItemType == typeof(IContentType).Name))
{ {
@@ -109,19 +109,19 @@ namespace Umbraco.Web.Cache
base.Refresh(payloads); base.Refresh(payloads);
} }
private IEnumerable<JsonPayload> GetMissingContentTypePayloads(JsonPayload[] payloads) //private IEnumerable<JsonPayload> GetMissingContentTypePayloads(JsonPayload[] payloads)
{ //{
var existingPayloadIds = new HashSet<int>(payloads.Select(x => x.Id)); // var existingPayloadIds = new HashSet<int>(payloads.Select(x => x.Id));
var contentTypeIds = _contentTypeService.GetAll().Select(x => x.Id).ToArray(); // var contentTypeIds = _contentTypeService.GetAll().Select(x => x.Id).ToArray();
foreach (var contentTypeId in contentTypeIds) // foreach (var contentTypeId in contentTypeIds)
{ // {
if (!existingPayloadIds.Contains(contentTypeId)) // if (!existingPayloadIds.Contains(contentTypeId))
{ // {
yield return new JsonPayload(typeof(IContentType).Name, contentTypeId, ContentTypeChangeTypes.RefreshOther); // yield return new JsonPayload(typeof(IContentType).Name, contentTypeId, ContentTypeChangeTypes.RefreshOther);
} // }
} // }
} //}
public override void RefreshAll() public override void RefreshAll()
{ {