From a9fc88d7e6d558dfbe8e1097c222e3e01e0cefad Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Mon, 14 Apr 2025 17:45:57 +0200 Subject: [PATCH] Make sure not to early return when verifying ancestor path is published without completing scope (#19029) * Make sure not to early return when verifying ancestor path is published without completing scope. * Added comment. --- .../Services/DocumentCacheService.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs b/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs index 21758a1fcd..f78863e64f 100644 --- a/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs +++ b/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Caching.Hybrid; +using Microsoft.Extensions.Caching.Hybrid; using Microsoft.Extensions.Options; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Models; @@ -115,12 +115,10 @@ internal sealed class DocumentCacheService : IDocumentCacheService // When unpublishing a node, a payload with RefreshBranch is published, so we don't have to worry about this. // Similarly, when a branch is published, next time the content is requested, the parent will be published, // this works because we don't cache null values. - if (preview is false && contentCacheNode is not null) + if (preview is false && contentCacheNode is not null && HasPublishedAncestorPath(contentCacheNode.Key) is false) { - if (HasPublishedAncestorPath(contentCacheNode.Key) is false) - { - return null; - } + // Careful not to early return here. We need to complete the scope even if returning null. + contentCacheNode = null; } scope.Complete();