Skip to content

Commit

Permalink
Ensure content types are updated in ContentStore when a data type cha…
Browse files Browse the repository at this point in the history
…nges (#15239)
  • Loading branch information
kjac authored Nov 17, 2023
1 parent 960d70e commit f286b11
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Umbraco.PublishedCache.NuCache/ContentStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,16 +736,22 @@ public void UpdateDataTypesLocked(IEnumerable<int> dataTypeIds, Func<int, IPubli
{
EnsureLocked();

IPublishedContentType?[] contentTypes = _contentTypesById
IPublishedContentType[] contentTypes = _contentTypesById
.Where(kvp =>
kvp.Value.Value != null &&
kvp.Value.Value.PropertyTypes.Any(p => dataTypeIds.Contains(p.DataType.Id)))
.Select(kvp => kvp.Value.Value)
.Select(x => getContentType(x!.Id))
.Where(x => x != null) // poof, gone, very unlikely and probably an anomaly
.WhereNotNull() // poof, gone, very unlikely and probably an anomaly
.ToArray();

var contentTypeIdsA = contentTypes.Select(x => x!.Id).ToArray();
// all content types that are affected by this data type update must be updated
foreach (IPublishedContentType contentType in contentTypes)
{
SetContentTypeLocked(contentType);
}

var contentTypeIdsA = contentTypes.Select(x => x.Id).ToArray();
var contentTypeNodes = new Dictionary<int, List<int>>();
foreach (var id in contentTypeIdsA)
{
Expand All @@ -761,7 +767,7 @@ public void UpdateDataTypesLocked(IEnumerable<int> dataTypeIds, Func<int, IPubli
}
}

foreach (IPublishedContentType contentType in contentTypes.WhereNotNull())
foreach (IPublishedContentType contentType in contentTypes)
{
// again, weird situation
if (contentTypeNodes.ContainsKey(contentType.Id) == false)
Expand Down

0 comments on commit f286b11

Please sign in to comment.