U4-7939 - fix routes cache

This commit is contained in:
Stephan
2016-02-11 11:53:03 +01:00
parent 33aa04bb2f
commit d6b46e7e78
3 changed files with 52 additions and 9 deletions

View File

@@ -57,12 +57,12 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (content != null && preview == false)
{
var domainRootNodeId = route.StartsWith("/") ? -1 : int.Parse(route.Substring(0, route.IndexOf('/')));
var iscanon =
UnitTesting == false
var iscanon =
UnitTesting == false
&& DomainHelper.ExistsDomainInPath(umbracoContext.Application.Services.DomainService.GetAll(false), content.Path, domainRootNodeId) == false;
// and only if this is the canonical url (the one GetUrl would return)
if (iscanon)
_routesCache.Store(contentId, route);
_routesCache.Store(content.Id, route);
}
return content;
@@ -159,7 +159,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
// we add this check - we look for the document matching "/" and if it's not us, then
// we do not hide the top level path
// it has to be taken care of in GetByRoute too so if
// "/foo" fails (looking for "/*/foo") we try also "/foo".
// "/foo" fails (looking for "/*/foo") we try also "/foo".
// this does not make much sense anyway esp. if both "/foo/" and "/bar/foo" exist, but
// that's the way it works pre-4.10 and we try to be backward compat for the time being
if (node.Parent == null)
@@ -244,8 +244,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
private static IPublishedContent ConvertToDocument(XmlNode xmlNode, bool isPreviewing)
{
return xmlNode == null
? null
return xmlNode == null
? null
: (new XmlPublishedContent(xmlNode, isPreviewing)).CreateModel();
}
@@ -398,7 +398,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (startNodeId > 0)
{
// if in a domain then use the root node of the domain
xpath = string.Format(XPathStringsDefinition.Root + XPathStrings.DescendantDocumentById, startNodeId);
xpath = string.Format(XPathStringsDefinition.Root + XPathStrings.DescendantDocumentById, startNodeId);
}
else
{
@@ -409,7 +409,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
// umbraco does not consistently guarantee that sortOrder starts with 0
// so the one that we want is the one with the smallest sortOrder
// read http://stackoverflow.com/questions/1128745/how-can-i-use-xpath-to-find-the-minimum-value-of-an-attribute-in-a-set-of-elemen
// so that one does not work, because min(@sortOrder) maybe 1
// xpath = "/root/*[@isDoc and @sortOrder='0']";
@@ -453,7 +453,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
else
{
xpathBuilder.AppendFormat(XPathStrings.ChildDocumentByUrlName, part);
}
}