From 993c582bd910c31af7ea913e6e4b1d94d825786d Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Tue, 1 Mar 2022 13:51:21 +0100 Subject: [PATCH] Handle empty string as invariant when generating cache key --- .../Routing/RedirectTrackingHandler.cs | 8 +++----- src/Umbraco.PublishedCache.NuCache/CacheKeys.cs | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs b/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs index f7c4a8ef0a..556c548cae 100644 --- a/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs +++ b/src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs @@ -118,8 +118,7 @@ namespace Umbraco.Cms.Core.Routing foreach (var culture in cultures) { - var checkedCulture = string.IsNullOrEmpty(culture) ? null : culture; - var route = contentCache.GetRouteById(publishedContent.Id, checkedCulture); + var route = contentCache.GetRouteById(publishedContent.Id, culture); if (IsNotRoute(route)) { continue; @@ -147,14 +146,13 @@ namespace Umbraco.Cms.Core.Routing foreach (KeyValuePair oldRoute in oldRoutes) { - var culture = string.IsNullOrWhiteSpace(oldRoute.Key.Culture) ? null : oldRoute.Key.Culture; - var newRoute = contentCache.GetRouteById(oldRoute.Key.ContentId, culture); + var newRoute = contentCache.GetRouteById(oldRoute.Key.ContentId, oldRoute.Key.Culture); if (IsNotRoute(newRoute) || oldRoute.Value.OldRoute == newRoute) { continue; } - _redirectUrlService.Register(oldRoute.Value.OldRoute, oldRoute.Value.ContentKey, culture); + _redirectUrlService.Register(oldRoute.Value.OldRoute, oldRoute.Value.ContentKey, oldRoute.Key.Culture); } } diff --git a/src/Umbraco.PublishedCache.NuCache/CacheKeys.cs b/src/Umbraco.PublishedCache.NuCache/CacheKeys.cs index 3d8f14afd3..0ec6f0b7cb 100644 --- a/src/Umbraco.PublishedCache.NuCache/CacheKeys.cs +++ b/src/Umbraco.PublishedCache.NuCache/CacheKeys.cs @@ -13,9 +13,7 @@ namespace Umbraco.Cms.Infrastructure.PublishedCache [MethodImpl(MethodImplOptions.AggressiveInlining)] private static string LangId(string culture) - { - return culture != null ? ("-L:" + culture) : string.Empty; - } + => string.IsNullOrEmpty(culture) ? string.Empty : ("-L:" + culture); public static string PublishedContentChildren(Guid contentUid, bool previewing) {