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:
@@ -1,10 +1,15 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Models.ContentPublishing;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.PublishedCache.HybridCache;
|
||||
|
||||
@@ -12,7 +17,11 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.PublishedCache.HybridCache;
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class DocumentHybridCacheScopeTests : UmbracoIntegrationTestWithContentEditing
|
||||
{
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder) => builder.AddUmbracoHybridCache();
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
||||
{
|
||||
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
builder.Services.AddUnique<IServerMessenger, ContentEventsTests.LocalServerMessenger>();
|
||||
}
|
||||
|
||||
private IPublishedContentCache PublishedContentHybridCache => GetRequiredService<IPublishedContentCache>();
|
||||
|
||||
@@ -81,4 +90,26 @@ public class DocumentHybridCacheScopeTests : UmbracoIntegrationTestWithContentEd
|
||||
// Published page should not be in cache, as we rolled scope back.
|
||||
Assert.IsNotNull(publishedPage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Can_Save_And_Publish_In_Same_Scope()
|
||||
{
|
||||
var key = Guid.NewGuid();
|
||||
using (var scope = CoreScopeProvider.CreateCoreScope())
|
||||
{
|
||||
Textpage.Key = key;
|
||||
var result = await ContentEditingService.CreateAsync(Textpage, Constants.Security.SuperUserKey);
|
||||
Assert.IsTrue(result);
|
||||
var publishResult = await ContentPublishingService.PublishAsync(Textpage.Key.Value, new List<CulturePublishScheduleModel>
|
||||
{
|
||||
new() { Culture = "*" },
|
||||
}, Constants.Security.SuperUserKey);
|
||||
Assert.IsTrue(publishResult.Success);
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
var published = await PublishedContentHybridCache.GetByIdAsync(key);
|
||||
Assert.IsNotNull(published);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user