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.
This commit is contained in:
Andy Butland
2025-04-14 17:45:57 +02:00
committed by kjac
parent 7495c3c7b2
commit a9fc88d7e6

View File

@@ -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();