From aa4dc64a5700811f258b4a284da82ea90ac61147 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 10 May 2018 23:07:33 +1000 Subject: [PATCH] Fixes ContentCache.GetRouteByIdInternal to ensure that no route is returned for any variant in the path of an unpublished variant of the same culture --- src/Umbraco.Web/PublishedCache/IDomainCache.cs | 13 +++++++++++++ .../PublishedCache/NuCache/ContentCache.cs | 14 ++++++++------ .../XmlPublishedCache/DomainCache.cs | 13 ++----------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/IDomainCache.cs b/src/Umbraco.Web/PublishedCache/IDomainCache.cs index bace337862..dbee8908a0 100644 --- a/src/Umbraco.Web/PublishedCache/IDomainCache.cs +++ b/src/Umbraco.Web/PublishedCache/IDomainCache.cs @@ -5,8 +5,21 @@ namespace Umbraco.Web.PublishedCache { public interface IDomainCache { + /// + /// Returns all in the current domain cache including any domains that may be referenced by content items that are no longer published + /// + /// + /// IEnumerable GetAll(bool includeWildcards); + + /// + /// Returns all assigned for the content id specified even if the content item is not published + /// + /// + /// + /// IEnumerable GetAssigned(int contentId, bool includeWildcards); + string DefaultCulture { get; } } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs index 0ad7c83a08..98701ebf67 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs @@ -144,22 +144,24 @@ namespace Umbraco.Web.PublishedCache.NuCache // or we reach the content root, collecting urls in the way var pathParts = new List(); var n = node; + var urlSegment = n.GetUrlSegment(culture); var hasDomains = _domainHelper.NodeHasDomains(n.Id); while (hasDomains == false && n != null) // n is null at root - { - var urlSegment = n.GetUrlSegment(culture); - - // without a segment, we cannot continue, really - if (urlSegment.IsNullOrWhiteSpace()) - return null; + { + // no segment indicates this is not published when this is a variant + if (urlSegment.IsNullOrWhiteSpace()) return null; pathParts.Add(urlSegment); // move to parent node n = n.Parent; + urlSegment = n.GetUrlSegment(culture); hasDomains = n != null && _domainHelper.NodeHasDomains(n.Id); } + // at this point this will be the urlSegment of the root, no segment indicates this is not published when this is a variant + if (urlSegment.IsNullOrWhiteSpace()) return null; + // no domain, respect HideTopLevelNodeFromPath for legacy purposes if (hasDomains == false && hideTopLevelNode.Value) ApplyHideTopLevelNodeFromPath(node, pathParts, preview); diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/DomainCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/DomainCache.cs index a64dbb7916..4571e9d42b 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/DomainCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/DomainCache.cs @@ -17,11 +17,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache DefaultCulture = defaultCultureAccessor.DefaultCulture; } - /// - /// Returns all in the current domain cache including any domains that may be referenced by content items that are no longer published - /// - /// - /// + /// public IEnumerable GetAll(bool includeWildcards) { return _domainService.GetAll(includeWildcards) @@ -29,12 +25,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache .Select(x => new Domain(x.Id, x.DomainName, x.RootContentId.Value, CultureInfo.GetCultureInfo(x.LanguageIsoCode), x.IsWildcard)); } - /// - /// Returns all assigned for the content id specified even if the content item is not published - /// - /// - /// - /// + /// public IEnumerable GetAssigned(int contentId, bool includeWildcards) { return _domainService.GetAssignedDomains(contentId, includeWildcards)