From 75d685ef433f3193b3cb61ae9104d7e4dfdb5d4f Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 5 Jul 2018 17:08:40 +0200 Subject: [PATCH] NuCache - fix parent published --- .../PublishedCache/NuCache/ContentNodeKit.cs | 4 ++-- .../PublishedCache/NuCache/ContentStore.cs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs index f284d54cf1..5a47b99382 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs @@ -17,9 +17,9 @@ namespace Umbraco.Web.PublishedCache.NuCache public static ContentNodeKit Null { get; } = new ContentNodeKit { ContentTypeId = -1 }; - public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor) + public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, bool canBePublished) { - Node.SetContentTypeAndData(contentType, DraftData, PublishedData, publishedSnapshotAccessor, variationContextAccessor); + Node.SetContentTypeAndData(contentType, DraftData, canBePublished ? PublishedData : null, publishedSnapshotAccessor, variationContextAccessor); } } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs index 303f4fc2ba..834594af9e 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs @@ -415,8 +415,11 @@ namespace Umbraco.Web.PublishedCache.NuCache if (_contentTypesById.TryGetValue(kit.ContentTypeId, out LinkedNode link) == false || link.Value == null) return false; + // check whether parent is published + var canBePublished = ParentPublishedLocked(kit); + // and use - kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor); + kit.Build(link.Value, _publishedSnapshotAccessor, _variationContextAccessor, canBePublished); return true; } @@ -643,6 +646,15 @@ namespace Umbraco.Web.PublishedCache.NuCache return link?.Value != null; } + private bool ParentPublishedLocked(ContentNodeKit kit) + { + if (kit.Node.ParentContentId < 0) + return true; + var link = GetParentLink(kit.Node); + var node = link?.Value; + return node?.Published != null; + } + private void AddToParentLocked(ContentNode content) { // add to root content index,