Skip to content

Commit 4781fb1

Browse files
kjacbergmania
authored andcommitted
Ensure content types are updated in ContentStore when a data type changes (#15239)
1 parent d714741 commit 4781fb1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Umbraco.PublishedCache.NuCache/ContentStore.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,16 +736,22 @@ public void UpdateDataTypesLocked(IEnumerable<int> dataTypeIds, Func<int, IPubli
736736
{
737737
EnsureLocked();
738738

739-
IPublishedContentType?[] contentTypes = _contentTypesById
739+
IPublishedContentType[] contentTypes = _contentTypesById
740740
.Where(kvp =>
741741
kvp.Value.Value != null &&
742742
kvp.Value.Value.PropertyTypes.Any(p => dataTypeIds.Contains(p.DataType.Id)))
743743
.Select(kvp => kvp.Value.Value)
744744
.Select(x => getContentType(x!.Id))
745-
.Where(x => x != null) // poof, gone, very unlikely and probably an anomaly
745+
.WhereNotNull() // poof, gone, very unlikely and probably an anomaly
746746
.ToArray();
747747

748-
var contentTypeIdsA = contentTypes.Select(x => x!.Id).ToArray();
748+
// all content types that are affected by this data type update must be updated
749+
foreach (IPublishedContentType contentType in contentTypes)
750+
{
751+
SetContentTypeLocked(contentType);
752+
}
753+
754+
var contentTypeIdsA = contentTypes.Select(x => x.Id).ToArray();
749755
var contentTypeNodes = new Dictionary<int, List<int>>();
750756
foreach (var id in contentTypeIdsA)
751757
{
@@ -761,7 +767,7 @@ public void UpdateDataTypesLocked(IEnumerable<int> dataTypeIds, Func<int, IPubli
761767
}
762768
}
763769

764-
foreach (IPublishedContentType contentType in contentTypes.WhereNotNull())
770+
foreach (IPublishedContentType contentType in contentTypes)
765771
{
766772
// again, weird situation
767773
if (contentTypeNodes.ContainsKey(contentType.Id) == false)

0 commit comments

Comments
 (0)