V15: Only cache items if all ancestors are published (#18337)
* Introduce IsDocumentPublishedInAnyCulture Sometimes we don't care about culture * Check ancestor path when resolving cache items * Fix tests * Rebuild NavigationService * Only set node if it has a published ancestor path * Remove branch when unpublished * Add tests * Add seed test * Consider published ancestor path when seeding documents * Introduce MediaBreadthFirstKeyProviderTests This is needed since the logic of document and media is no longer the same * Remove unused services * Move assert page to helper * Add variant tests * Add tests * Filter keys in ContentTypeSeedKeyProvider * Fix tests * Add failing test showing refreshing issue * Don't blow up if we can't resolve the node from navigation cache Turns out that this can actually happen :D Should be fine to just return false * Refactor cache refresher check * Make NavigationQueryService service protected * Add comment on how to refactor breadth first key provider * Refactor if statement
This commit is contained in:
@@ -172,9 +172,20 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
var branchKeys = descendantsKeys.ToList();
|
||||
branchKeys.Add(key);
|
||||
|
||||
foreach (Guid branchKey in branchKeys)
|
||||
// If the branch is unpublished, we need to remove it from cache instead of refreshing it
|
||||
if (IsBranchUnpublished(payload))
|
||||
{
|
||||
_documentCacheService.RefreshMemoryCacheAsync(branchKey).GetAwaiter().GetResult();
|
||||
foreach (Guid branchKey in branchKeys)
|
||||
{
|
||||
_documentCacheService.RemoveFromMemoryCacheAsync(branchKey).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Guid branchKey in branchKeys)
|
||||
{
|
||||
_documentCacheService.RefreshMemoryCacheAsync(branchKey).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,6 +201,15 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsBranchUnpublished(JsonPayload payload)
|
||||
{
|
||||
// If unpublished cultures has one or more values, but published cultures does not, this means that the branch is unpublished entirely
|
||||
// And therefore should no longer be resolve-able from the cache, so we need to remove it instead.
|
||||
// Otherwise, some culture is still published, so it should be resolve-able from cache, and published cultures should instead be used.
|
||||
return payload.UnpublishedCultures is not null && payload.UnpublishedCultures.Length != 0 &&
|
||||
(payload.PublishedCultures is null || payload.PublishedCultures.Length == 0);
|
||||
}
|
||||
|
||||
private void HandleNavigation(JsonPayload payload)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user