Skip to content

Commit 993c582

Browse files
author
nikolajlauridsen
committed
Handle empty string as invariant when generating cache key
1 parent dfbb182 commit 993c582

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/Umbraco.Infrastructure/Routing/RedirectTrackingHandler.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ private void StoreOldRoute(IContent entity, OldRoutesDictionary oldRoutes)
118118

119119
foreach (var culture in cultures)
120120
{
121-
var checkedCulture = string.IsNullOrEmpty(culture) ? null : culture;
122-
var route = contentCache.GetRouteById(publishedContent.Id, checkedCulture);
121+
var route = contentCache.GetRouteById(publishedContent.Id, culture);
123122
if (IsNotRoute(route))
124123
{
125124
continue;
@@ -147,14 +146,13 @@ private void CreateRedirects(OldRoutesDictionary oldRoutes)
147146

148147
foreach (KeyValuePair<ContentIdAndCulture, ContentKeyAndOldRoute> oldRoute in oldRoutes)
149148
{
150-
var culture = string.IsNullOrWhiteSpace(oldRoute.Key.Culture) ? null : oldRoute.Key.Culture;
151-
var newRoute = contentCache.GetRouteById(oldRoute.Key.ContentId, culture);
149+
var newRoute = contentCache.GetRouteById(oldRoute.Key.ContentId, oldRoute.Key.Culture);
152150
if (IsNotRoute(newRoute) || oldRoute.Value.OldRoute == newRoute)
153151
{
154152
continue;
155153
}
156154

157-
_redirectUrlService.Register(oldRoute.Value.OldRoute, oldRoute.Value.ContentKey, culture);
155+
_redirectUrlService.Register(oldRoute.Value.OldRoute, oldRoute.Value.ContentKey, oldRoute.Key.Culture);
158156
}
159157
}
160158

src/Umbraco.PublishedCache.NuCache/CacheKeys.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ private static string DraftOrPub(bool previewing)
1313

1414
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1515
private static string LangId(string culture)
16-
{
17-
return culture != null ? ("-L:" + culture) : string.Empty;
18-
}
16+
=> string.IsNullOrEmpty(culture) ? string.Empty : ("-L:" + culture);
1917

2018
public static string PublishedContentChildren(Guid contentUid, bool previewing)
2119
{

0 commit comments

Comments
 (0)