removes the weird IsInitialPublishedContent

This commit is contained in:
Shannon
2021-01-06 17:31:46 +11:00
parent 295ab504cd
commit f5bd53b223
7 changed files with 15 additions and 51 deletions

View File

@@ -25,13 +25,6 @@ namespace Umbraco.Web.Routing
/// </summary>
IPublishedContent PublishedContent { get; }
/// <summary>
/// Gets the initial requested content.
/// </summary>
/// <remarks>The initial requested content is the content that was found by the finders,
/// before anything such as 404, redirect... took place.</remarks>
IPublishedContent InitialPublishedContent { get; }
/// <summary>
/// Gets a value indicating whether the current published content has been obtained
/// from the initial published content following internal redirections exclusively.

View File

@@ -28,11 +28,6 @@ namespace Umbraco.Web.Routing
/// </summary>
CultureInfo Culture { get; }
/// <summary>
/// Gets a value indicating whether the current published content is the initial one.
/// </summary>
bool IsInitialPublishedContent { get; }
/// <summary>
/// Gets a value indicating whether the current published content has been obtained
/// from the initial published content following internal redirections exclusively.
@@ -84,11 +79,6 @@ namespace Umbraco.Web.Routing
/// preserve or reset the template, if any.</remarks>
IPublishedRequestBuilder SetInternalRedirectPublishedContent(IPublishedContent content);
/// <summary>
/// Indicates that the current PublishedContent is the initial one.
/// </summary>
IPublishedRequestBuilder SetIsInitialPublishedContent(); // TODO: Required?
/// <summary>
/// Tries to set the template to use to display the requested content.
/// </summary>

View File

@@ -76,10 +76,7 @@ namespace Umbraco.Web.Routing
public bool CacheabilityNoCache { get; }
}
/// <summary>
/// Represents a request for one specified Umbraco IPublishedContent to be rendered
/// by one specified template, using one specified Culture and RenderingEngine.
/// </summary>
// TODO: Kill this, but we need to port all of it's functionality
public class PublishedRequestOld // : IPublishedRequest
{
private readonly IPublishedRouter _publishedRouter;

View File

@@ -16,7 +16,6 @@ namespace Umbraco.Web.Routing
private bool _cacheability;
private IReadOnlyList<string> _cacheExtensions;
private IPublishedContent _internalRedirectContent;
private bool _isInitContent;
private string _redirectUrl;
private HttpStatusCode _responseStatus = HttpStatusCode.NotFound;
private string _responseDesc;
@@ -41,9 +40,6 @@ namespace Umbraco.Web.Routing
/// <inheritdoc/>
public ITemplate Template { get; private set; }
/// <inheritdoc/>
public bool IsInitialPublishedContent { get; private set; }
/// <inheritdoc/>
public bool IsInternalRedirectPublishedContent { get; private set; } // TODO: Not sure what this is yet
@@ -124,13 +120,6 @@ namespace Umbraco.Web.Routing
return this;
}
/// <inheritdoc/>
public IPublishedRequestBuilder SetIsInitialPublishedContent()
{
_isInitContent = true;
return this;
}
/// <inheritdoc/>
public IPublishedRequestBuilder SetPublishedContent(IPublishedContent content)
{

View File

@@ -55,11 +55,6 @@ namespace Umbraco.Web.Routing
/// </summary>
public static bool IsRedirectPermanent(this IPublishedRequest publishedRequest) => publishedRequest.ResponseStatusCode == (int)HttpStatusCode.Moved;
/// <summary>
/// Gets a value indicating whether the current published content is the initial one.
/// </summary>
public static bool IsInitialPublishedContent(this IPublishedRequest publishedRequest) => publishedRequest.InitialPublishedContent != null;
/// <summary>
/// Gets a value indicating whether the content request has a domain.
/// </summary>

View File

@@ -318,13 +318,15 @@ namespace Umbraco.Web.Routing
internal bool FindTemplateRenderingEngineInDirectory(DirectoryInfo directory, string alias, string[] extensions)
{
if (directory == null || directory.Exists == false)
{
return false;
}
var pos = alias.IndexOf('/');
if (pos > 0)
{
// recurse
var subdir = directory.GetDirectories(alias.Substring(0, pos)).FirstOrDefault();
DirectoryInfo subdir = directory.GetDirectories(alias.Substring(0, pos)).FirstOrDefault();
alias = alias.Substring(pos + 1);
return subdir != null && FindTemplateRenderingEngineInDirectory(subdir, alias, extensions);
}
@@ -351,6 +353,8 @@ namespace Umbraco.Web.Routing
return;
}
var foundContentByFinders = request.HasPublishedContent();
// not handling umbracoRedirect here but after LookupDocument2
// so internal redirect, 404, etc has precedence over redirect
@@ -358,7 +362,7 @@ namespace Umbraco.Web.Routing
HandlePublishedContent(request);
// find a template
FindTemplate(request);
FindTemplate(request, foundContentByFinders);
// handle umbracoRedirect
FollowExternalRedirect(request);
@@ -375,7 +379,6 @@ namespace Umbraco.Web.Routing
// look for the document
// the first successful finder, if any, will set this.PublishedContent, and may also set this.Template
// some finders may implement caching
using (_profilingLogger.DebugDuration<PublishedRouter>(
$"{tracePrefix}Begin finders",
$"{tracePrefix}End finders"))
@@ -387,10 +390,6 @@ namespace Umbraco.Web.Routing
return finder.TryFindContent(request);
});
}
// indicate that the published content (if any) we have at the moment is the
// one that was found by the standard finders before anything else took place.
request.SetIsInitialPublishedContent();
}
/// <summary>
@@ -588,7 +587,9 @@ namespace Umbraco.Web.Routing
/// <summary>
/// Finds a template for the current node, if any.
/// </summary>
private void FindTemplate(IPublishedRequestBuilder request)
/// <param name="request">The request builder.</param>
/// <param name="contentFoundByFinders">If the content was found by the finders, before anything such as 404, redirect... took place.</param>
private void FindTemplate(IPublishedRequestBuilder request, bool contentFoundByFinders)
{
// TODO: We've removed the event, might need to re-add?
// NOTE: at the moment there is only 1 way to find a template, and then ppl must
@@ -604,7 +605,7 @@ namespace Umbraco.Web.Routing
// only if the published content is the initial once, else the alternate template
// does not apply
// + optionally, apply the alternate template on internal redirects
var useAltTemplate = request.IsInitialPublishedContent
var useAltTemplate = contentFoundByFinders
|| (_webRoutingSettings.InternalRedirectPreservesTemplate && request.IsInternalRedirectPublishedContent);
var altTemplate = useAltTemplate

View File

@@ -218,15 +218,14 @@ namespace Umbraco.Web.Website.Routing
// ok, process
// note: requestModule.UmbracoRewrite also did some stripping of &umbPage
// from the querystring... that was in v3.x to fix some issues with pre-forms
// auth. Paul Sterling confirmed in Jan. 2013 that we can get rid of it.
// instantiate, prepare and process the published content request
// important to use CleanedUmbracoUrl - lowercase path-only version of the current url
IPublishedRequestBuilder requestBuilder = _publishedRouter.CreateRequest(umbracoContext.CleanedUmbracoUrl);
// TODO: This is ugly with the re-assignment to umbraco context
// TODO: This is ugly with the re-assignment to umbraco context but at least its now
// an immutable object. The only way to make this better would be to have a RouteRequest
// as part of UmbracoContext but then it will require a PublishedRouter dependency so not sure that's worth it.
// Maybe could be a one-time Set method instead?
publishedRequest = umbracoContext.PublishedRequest = _publishedRouter.RouteRequest(requestBuilder);
return publishedRequest.Success() && publishedRequest.HasPublishedContent();