#10354 - added domain content id as node context for the content finder for the 404 error page so $site works

This commit is contained in:
Kevin Meilander
2021-05-28 10:39:59 -05:00
committed by Sebastiaan Janssen
parent 0bc9f3e322
commit 1dd75b9051
2 changed files with 12 additions and 6 deletions

View File

@@ -33,11 +33,14 @@ namespace Umbraco.Web.Routing
{
_logger.Debug<ContentFinderByConfigured404>("Looking for a page to handle 404.");
int? domainConentId = null;
// try to find a culture as best as we can
var errorCulture = CultureInfo.CurrentUICulture;
if (frequest.HasDomain)
{
errorCulture = frequest.Domain.Culture;
domainConentId = frequest.Domain.ContentId;
}
else
{
@@ -63,7 +66,9 @@ namespace Umbraco.Web.Routing
_contentConfigSection.Error404Collection.ToArray(),
_entityService,
new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor),
errorCulture);
errorCulture,
domainConentId
);
IPublishedContent content = null;

View File

@@ -41,7 +41,8 @@ namespace Umbraco.Web.Routing
IContentErrorPage[] error404Collection,
IEntityService entityService,
IPublishedContentQuery publishedContentQuery,
CultureInfo errorCulture)
CultureInfo errorCulture,
int? domainContentId)
{
if (error404Collection.Length > 1)
{
@@ -50,11 +51,11 @@ namespace Umbraco.Web.Routing
?? error404Collection.FirstOrDefault(x => x.Culture == "default"); // there should be a default one!
if (cultureErr != null)
return GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery);
return GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery, domainContentId);
}
else
{
return GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery);
return GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery, domainContentId);
}
return null;
@@ -67,7 +68,7 @@ namespace Umbraco.Web.Routing
/// <param name="entityService"></param>
/// <param name="publishedContentQuery"></param>
/// <returns></returns>
internal static int? GetContentIdFromErrorPageConfig(IContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery)
internal static int? GetContentIdFromErrorPageConfig(IContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery, int? domainContentId)
{
if (errorPage.HasContentId) return errorPage.ContentId;
@@ -92,7 +93,7 @@ namespace Umbraco.Web.Routing
//we have an xpath statement to execute
var xpathResult = UmbracoXPathPathSyntaxParser.ParseXPathQuery(
xpathExpression: errorPage.ContentXPath,
nodeContextId: null,
nodeContextId: domainContentId,
getPath: nodeid =>
{
var ent = entityService.Get(nodeid);