Skip to content

Commit 9bd3076

Browse files
committed
Register no-op implementation of IMemberPartialViewCacheInvalidator in headless setups (#19666)
* Register no-op implementation of IMemberPartialViewCacheInvalidator in headless setups. * Tidied usings. # Conflicts: # src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs
1 parent 118b26a commit 9bd3076

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Umbraco.Cms.Core.Cache.PartialViewCacheInvalidators;
2+
3+
internal class NoopMemberPartialViewCacheInvalidator : IMemberPartialViewCacheInvalidator
4+
{
5+
public void ClearPartialViewCacheItems(IEnumerable<int> memberIds)
6+
{
7+
// No operation performed, this is a no-op implementation.
8+
}
9+
}

src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
using Microsoft.Extensions.Logging.Abstractions;
99
using Microsoft.Extensions.Options;
1010
using Umbraco.Cms.Core.Cache;
11+
using Umbraco.Cms.Core.Cache.PartialViewCacheInvalidators;
1112
using Umbraco.Cms.Core.Composing;
1213
using Umbraco.Cms.Core.Configuration;
1314
using Umbraco.Cms.Core.Configuration.Models;
1415
using Umbraco.Cms.Core.Diagnostics;
1516
using Umbraco.Cms.Core.Dictionary;
17+
using Umbraco.Cms.Core.DynamicRoot;
1618
using Umbraco.Cms.Core.Editors;
1719
using Umbraco.Cms.Core.Events;
1820
using Umbraco.Cms.Core.Features;
@@ -32,7 +34,6 @@
3234
using Umbraco.Cms.Core.Security;
3335
using Umbraco.Cms.Core.Services;
3436
using Umbraco.Cms.Core.Services.ContentTypeEditing;
35-
using Umbraco.Cms.Core.DynamicRoot;
3637
using Umbraco.Cms.Core.Preview;
3738
using Umbraco.Cms.Core.PublishedCache;
3839
using Umbraco.Cms.Core.PublishedCache.Internal;
@@ -389,6 +390,11 @@ private void AddCoreServices()
389390
Services.AddUnique<IDataTypeConfigurationCache, DataTypeConfigurationCache>();
390391
Services.AddNotificationHandler<DataTypeCacheRefresherNotification, DataTypeConfigurationCacheRefresher>();
391392

393+
// Partial view cache invalidators (no-op, shipped implementation is added in Umbraco.Web.Website, but we
394+
// need this to ensure we have a service registered for this interface even in headless setups).
395+
// See: https://github.com/umbraco/Umbraco-CMS/issues/19661
396+
Services.AddUnique<IMemberPartialViewCacheInvalidator, NoopMemberPartialViewCacheInvalidator>();
397+
392398
// Two factor providers
393399
Services.AddUnique<ITwoFactorLoginService, TwoFactorLoginService>();
394400
Services.AddUnique<IUserTwoFactorLoginService, UserTwoFactorLoginService>();

src/Umbraco.Web.Website/Cache/PartialViewCacheInvalidators/MemberPartialViewCacheInvalidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void ClearPartialViewCacheItems(IEnumerable<int> memberIds)
3232
_appCaches.RuntimeCache.ClearByRegex($"{CoreCacheHelperExtensions.PartialViewCacheKey}.*-m{memberId}-*");
3333
}
3434

35-
// since it is possible to add a cache item linked to members without a member logged in, we should always clear these items.
35+
// Since it is possible to add a cache item linked to members without a member logged in, we should always clear these items.
3636
_appCaches.RuntimeCache.ClearByRegex($"{CoreCacheHelperExtensions.PartialViewCacheKey}.*-m-*");
3737
}
3838
}

0 commit comments

Comments
 (0)