Fixes ContentCache.GetRouteByIdInternal to ensure that no route is returned for any variant in the path of an unpublished variant of the same culture

This commit is contained in:
Shannon
2018-05-10 23:07:33 +10:00
parent d78fa85307
commit aa4dc64a57
3 changed files with 23 additions and 17 deletions

View File

@@ -5,8 +5,21 @@ namespace Umbraco.Web.PublishedCache
{
public interface IDomainCache
{
/// <summary>
/// Returns all <see cref="Domain"/> in the current domain cache including any domains that may be referenced by content items that are no longer published
/// </summary>
/// <param name="includeWildcards"></param>
/// <returns></returns>
IEnumerable<Domain> GetAll(bool includeWildcards);
/// <summary>
/// Returns all assigned <see cref="Domain"/> for the content id specified even if the content item is not published
/// </summary>
/// <param name="contentId"></param>
/// <param name="includeWildcards"></param>
/// <returns></returns>
IEnumerable<Domain> GetAssigned(int contentId, bool includeWildcards);
string DefaultCulture { get; }
}
}

View File

@@ -144,22 +144,24 @@ namespace Umbraco.Web.PublishedCache.NuCache
// or we reach the content root, collecting urls in the way
var pathParts = new List<string>();
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);

View File

@@ -17,11 +17,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
DefaultCulture = defaultCultureAccessor.DefaultCulture;
}
/// <summary>
/// Returns all <see cref="Domain"/> in the current domain cache including any domains that may be referenced by content items that are no longer published
/// </summary>
/// <param name="includeWildcards"></param>
/// <returns></returns>
/// <inheritdoc />
public IEnumerable<Domain> 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));
}
/// <summary>
/// Returns all assigned <see cref="Domain"/> for the content id specified even if the content item is not published
/// </summary>
/// <param name="contentId"></param>
/// <param name="includeWildcards"></param>
/// <returns></returns>
/// <inheritdoc />
public IEnumerable<Domain> GetAssigned(int contentId, bool includeWildcards)
{
return _domainService.GetAssignedDomains(contentId, includeWildcards)