Skip to content

Commit 1dd75b9

Browse files
kmeilandernul800sebastiaan
authored andcommitted
umbraco#10354 - added domain content id as node context for the content finder for the 404 error page so $site works
1 parent 0bc9f3e commit 1dd75b9

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Umbraco.Web/Routing/ContentFinderByConfigured404.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ public bool TryFindContent(PublishedRequest frequest)
3333
{
3434
_logger.Debug<ContentFinderByConfigured404>("Looking for a page to handle 404.");
3535

36+
int? domainConentId = null;
37+
3638
// try to find a culture as best as we can
3739
var errorCulture = CultureInfo.CurrentUICulture;
3840
if (frequest.HasDomain)
3941
{
4042
errorCulture = frequest.Domain.Culture;
43+
domainConentId = frequest.Domain.ContentId;
4144
}
4245
else
4346
{
@@ -63,7 +66,9 @@ public bool TryFindContent(PublishedRequest frequest)
6366
_contentConfigSection.Error404Collection.ToArray(),
6467
_entityService,
6568
new PublishedContentQuery(frequest.UmbracoContext.PublishedSnapshot, frequest.UmbracoContext.VariationContextAccessor),
66-
errorCulture);
69+
errorCulture,
70+
domainConentId
71+
);
6772

6873
IPublishedContent content = null;
6974

src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ internal class NotFoundHandlerHelper
4141
IContentErrorPage[] error404Collection,
4242
IEntityService entityService,
4343
IPublishedContentQuery publishedContentQuery,
44-
CultureInfo errorCulture)
44+
CultureInfo errorCulture,
45+
int? domainContentId)
4546
{
4647
if (error404Collection.Length > 1)
4748
{
@@ -50,11 +51,11 @@ internal class NotFoundHandlerHelper
5051
?? error404Collection.FirstOrDefault(x => x.Culture == "default"); // there should be a default one!
5152

5253
if (cultureErr != null)
53-
return GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery);
54+
return GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery, domainContentId);
5455
}
5556
else
5657
{
57-
return GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery);
58+
return GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery, domainContentId);
5859
}
5960

6061
return null;
@@ -67,7 +68,7 @@ internal class NotFoundHandlerHelper
6768
/// <param name="entityService"></param>
6869
/// <param name="publishedContentQuery"></param>
6970
/// <returns></returns>
70-
internal static int? GetContentIdFromErrorPageConfig(IContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery)
71+
internal static int? GetContentIdFromErrorPageConfig(IContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery, int? domainContentId)
7172
{
7273
if (errorPage.HasContentId) return errorPage.ContentId;
7374

@@ -92,7 +93,7 @@ internal class NotFoundHandlerHelper
9293
//we have an xpath statement to execute
9394
var xpathResult = UmbracoXPathPathSyntaxParser.ParseXPathQuery(
9495
xpathExpression: errorPage.ContentXPath,
95-
nodeContextId: null,
96+
nodeContextId: domainContentId,
9697
getPath: nodeid =>
9798
{
9899
var ent = entityService.Get(nodeid);

0 commit comments

Comments
 (0)