Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10354 - added domain content id as node context for the content find… #10356

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public bool TryFindContent(PublishedRequest frequest)
{
_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
{
Expand All @@ -63,7 +66,9 @@ public bool TryFindContent(PublishedRequest frequest)
_contentConfigSection.Error404Collection.ToArray(),
_entityService,
new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor),
errorCulture);
errorCulture,
domainConentId
);

IPublishedContent content = null;

Expand Down
11 changes: 6 additions & 5 deletions src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ internal class NotFoundHandlerHelper
IContentErrorPage[] error404Collection,
IEntityService entityService,
IPublishedContentQuery publishedContentQuery,
CultureInfo errorCulture)
CultureInfo errorCulture,
int? domainContentId)
{
if (error404Collection.Length > 1)
{
Expand All @@ -50,11 +51,11 @@ internal class NotFoundHandlerHelper
?? 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;
Expand All @@ -67,7 +68,7 @@ internal class NotFoundHandlerHelper
/// <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;

Expand All @@ -92,7 +93,7 @@ internal class NotFoundHandlerHelper
//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);
Expand Down