Fixed ContentLastChanceFinder not being called for nodes without template (#12002)
This commit also ensure that the domain and culture is set before the ContentLastChanceFinder executes
This commit is contained in:
@@ -127,11 +127,18 @@ public class PublishedRouter : IPublishedRouter
|
||||
|
||||
IPublishedRequestBuilder builder = new PublishedRequestBuilder(request.Uri, _fileService);
|
||||
|
||||
// ensure we keep the previous domain and culture
|
||||
if (request.Domain is not null)
|
||||
{
|
||||
builder.SetDomain(request.Domain);
|
||||
}
|
||||
builder.SetCulture(request.Culture);
|
||||
|
||||
// set to the new content (or null if specified)
|
||||
builder.SetPublishedContent(publishedContent);
|
||||
|
||||
// re-route
|
||||
await RouteRequestInternalAsync(builder);
|
||||
await RouteRequestInternalAsync(builder, true);
|
||||
|
||||
// return if we are redirect
|
||||
if (builder.IsRedirect())
|
||||
@@ -147,11 +154,6 @@ public class PublishedRouter : IPublishedRouter
|
||||
builder.SetPublishedContent(content);
|
||||
}
|
||||
|
||||
if (!builder.HasDomain())
|
||||
{
|
||||
FindDomain(builder);
|
||||
}
|
||||
|
||||
return BuildRequest(builder);
|
||||
}
|
||||
|
||||
@@ -211,7 +213,7 @@ public class PublishedRouter : IPublishedRouter
|
||||
_variationContextAccessor.VariationContext = new VariationContext(culture);
|
||||
}
|
||||
|
||||
private async Task RouteRequestInternalAsync(IPublishedRequestBuilder builder)
|
||||
private async Task RouteRequestInternalAsync(IPublishedRequestBuilder builder, bool skipContentFinders = false)
|
||||
{
|
||||
// if request builder was already flagged to redirect then return
|
||||
// whoever called us is in charge of actually redirecting
|
||||
@@ -229,7 +231,7 @@ public class PublishedRouter : IPublishedRouter
|
||||
// This could be manually assigned with a custom route handler, etc...
|
||||
// which in turn could call this method
|
||||
// to setup the rest of the pipeline but we don't want to run the finders since there's one assigned.
|
||||
if (!builder.HasPublishedContent())
|
||||
if (!builder.HasPublishedContent() && !skipContentFinders)
|
||||
{
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
|
||||
@@ -75,17 +75,7 @@ public class UmbracoRouteValuesFactory : IUmbracoRouteValuesFactory
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
|
||||
string? customActionName = null;
|
||||
|
||||
// check that a template is defined), if it doesn't and there is a hijacked route it will just route
|
||||
// to the index Action
|
||||
if (request.HasTemplate())
|
||||
{
|
||||
// the template Alias should always be already saved with a safe name.
|
||||
// if there are hyphens in the name and there is a hijacked route, then the Action will need to be attributed
|
||||
// with the action name attribute.
|
||||
customActionName = request.GetTemplateAlias()?.Split('.')[0].ToSafeAlias(_shortStringHelper);
|
||||
}
|
||||
string? customActionName = GetTemplateName(request);
|
||||
|
||||
// The default values for the default controller/action
|
||||
var def = new UmbracoRouteValues(
|
||||
@@ -160,10 +150,12 @@ public class UmbracoRouteValuesFactory : IUmbracoRouteValuesFactory
|
||||
$"The call to {nameof(IPublishedRouter.UpdateRequestAsync)} cannot return null");
|
||||
}
|
||||
|
||||
string? customActionName = GetTemplateName(request);
|
||||
|
||||
def = new UmbracoRouteValues(
|
||||
request,
|
||||
def.ControllerActionDescriptor,
|
||||
def.TemplateName);
|
||||
customActionName);
|
||||
|
||||
// if the content has changed, we must then again check for hijacked routes
|
||||
if (content != request.PublishedContent)
|
||||
@@ -174,4 +166,19 @@ public class UmbracoRouteValuesFactory : IUmbracoRouteValuesFactory
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
private string? GetTemplateName(IPublishedRequest request)
|
||||
{
|
||||
// check that a template is defined), if it doesn't and there is a hijacked route it will just route
|
||||
// to the index Action
|
||||
if (request.HasTemplate())
|
||||
{
|
||||
// the template Alias should always be already saved with a safe name.
|
||||
// if there are hyphens in the name and there is a hijacked route, then the Action will need to be attributed
|
||||
// with the action name attribute.
|
||||
return request.GetTemplateAlias()?.Split('.')[0].ToSafeAlias(_shortStringHelper);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user