Skip to content

Commit 76e2103

Browse files
authored
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.
1 parent 449c94f commit 76e2103

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.Extensions.Caching.Hybrid;
1+
using Microsoft.Extensions.Caching.Hybrid;
22
using Microsoft.Extensions.Options;
33
using Umbraco.Cms.Core;
44
using Umbraco.Cms.Core.Models;
@@ -115,12 +115,10 @@ public DocumentCacheService(
115115
// When unpublishing a node, a payload with RefreshBranch is published, so we don't have to worry about this.
116116
// Similarly, when a branch is published, next time the content is requested, the parent will be published,
117117
// this works because we don't cache null values.
118-
if (preview is false && contentCacheNode is not null)
118+
if (preview is false && contentCacheNode is not null && HasPublishedAncestorPath(contentCacheNode.Key) is false)
119119
{
120-
if (HasPublishedAncestorPath(contentCacheNode.Key) is false)
121-
{
122-
return null;
123-
}
120+
// Careful not to early return here. We need to complete the scope even if returning null.
121+
contentCacheNode = null;
124122
}
125123

126124
scope.Complete();

0 commit comments

Comments
 (0)