Fix TypeLoader and PublishedRouter
This commit is contained in:
@@ -28,7 +28,8 @@ namespace Umbraco.Core.Composing
|
||||
private const string CacheKey = "umbraco-types.list";
|
||||
|
||||
private readonly IAppPolicyCache _runtimeCache;
|
||||
private readonly IProfilingLogger _logger;
|
||||
private readonly ILogger<TypeLoader> _logger;
|
||||
private readonly IProfilingLogger _profilingLogger;
|
||||
|
||||
private readonly Dictionary<CompositeTypeTypeKey, TypeList> _types = new Dictionary<CompositeTypeTypeKey, TypeList>();
|
||||
private readonly object _locko = new object();
|
||||
@@ -51,8 +52,8 @@ namespace Umbraco.Core.Composing
|
||||
/// <param name="localTempPath">Files storage location.</param>
|
||||
/// <param name="logger">A profiling logger.</param>
|
||||
/// <param name="assembliesToScan"></param>
|
||||
public TypeLoader(ITypeFinder typeFinder, IAppPolicyCache runtimeCache, DirectoryInfo localTempPath, IProfilingLogger logger, IEnumerable<Assembly> assembliesToScan = null)
|
||||
: this(typeFinder, runtimeCache, localTempPath, logger, true, assembliesToScan)
|
||||
public TypeLoader(ITypeFinder typeFinder, IAppPolicyCache runtimeCache, DirectoryInfo localTempPath, ILogger<TypeLoader> logger, IProfilingLogger profilingLogger, IEnumerable<Assembly> assembliesToScan = null)
|
||||
: this(typeFinder, runtimeCache, localTempPath, logger, profilingLogger, true, assembliesToScan)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
@@ -64,12 +65,13 @@ namespace Umbraco.Core.Composing
|
||||
/// <param name="logger">A profiling logger.</param>
|
||||
/// <param name="detectChanges">Whether to detect changes using hashes.</param>
|
||||
/// <param name="assembliesToScan"></param>
|
||||
public TypeLoader(ITypeFinder typeFinder, IAppPolicyCache runtimeCache, DirectoryInfo localTempPath, IProfilingLogger logger, bool detectChanges, IEnumerable<Assembly> assembliesToScan = null)
|
||||
public TypeLoader(ITypeFinder typeFinder, IAppPolicyCache runtimeCache, DirectoryInfo localTempPath, ILogger<TypeLoader> logger, IProfilingLogger profilingLogger, bool detectChanges, IEnumerable<Assembly> assembliesToScan = null)
|
||||
{
|
||||
TypeFinder = typeFinder ?? throw new ArgumentNullException(nameof(typeFinder));
|
||||
_runtimeCache = runtimeCache ?? throw new ArgumentNullException(nameof(runtimeCache));
|
||||
_localTempPath = localTempPath;
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_profilingLogger = profilingLogger ?? throw new ArgumentNullException(nameof(profilingLogger));
|
||||
_assemblies = assembliesToScan;
|
||||
|
||||
if (detectChanges)
|
||||
@@ -309,7 +311,7 @@ namespace Umbraco.Core.Composing
|
||||
// internal for tests
|
||||
public void WriteCache()
|
||||
{
|
||||
_logger.Debug<TypeLoader>("Writing cache file.");
|
||||
_logger.LogDebug("Writing cache file.");
|
||||
var typesListFilePath = GetTypesListFilePath();
|
||||
using (var stream = GetFileStream(typesListFilePath, FileMode.Create, FileAccess.Write, FileShare.None, ListFileOpenWriteTimeout))
|
||||
using (var writer = new StreamWriter(stream))
|
||||
@@ -381,7 +383,7 @@ namespace Umbraco.Core.Composing
|
||||
if (--attempts == 0)
|
||||
throw;
|
||||
|
||||
_logger.Debug<TypeLoader>("Attempted to get filestream for file {Path} failed, {NumberOfAttempts} attempts left, pausing for {PauseMilliseconds} milliseconds", path, attempts, pauseMilliseconds);
|
||||
_logger.LogDebug("Attempted to get filestream for file {Path} failed, {NumberOfAttempts} attempts left, pausing for {PauseMilliseconds} milliseconds", path, attempts, pauseMilliseconds);
|
||||
Thread.Sleep(pauseMilliseconds);
|
||||
}
|
||||
}
|
||||
@@ -402,7 +404,7 @@ namespace Umbraco.Core.Composing
|
||||
if (--attempts == 0)
|
||||
throw;
|
||||
|
||||
_logger.Debug<TypeLoader>("Attempted to delete file {Path} failed, {NumberOfAttempts} attempts left, pausing for {PauseMilliseconds} milliseconds", path, attempts, pauseMilliseconds);
|
||||
_logger.LogDebug("Attempted to delete file {Path} failed, {NumberOfAttempts} attempts left, pausing for {PauseMilliseconds} milliseconds", path, attempts, pauseMilliseconds);
|
||||
Thread.Sleep(pauseMilliseconds);
|
||||
}
|
||||
}
|
||||
@@ -475,7 +477,7 @@ namespace Umbraco.Core.Composing
|
||||
if (!typeof(IDiscoverable).IsAssignableFrom(typeof(T)))
|
||||
{
|
||||
// warn
|
||||
_logger.Debug<TypeLoader>("Running a full, " + (cache ? "" : "non-") + "cached, scan for non-discoverable type {TypeName} (slow).", typeof(T).FullName);
|
||||
_logger.LogDebug("Running a full, " + (cache ? "" : "non-") + "cached, scan for non-discoverable type {TypeName} (slow).", typeof(T).FullName);
|
||||
|
||||
return GetTypesInternal(
|
||||
typeof(T), null,
|
||||
@@ -493,7 +495,7 @@ namespace Umbraco.Core.Composing
|
||||
|
||||
// warn
|
||||
if (!cache)
|
||||
_logger.Debug<TypeLoader>("Running a non-cached, filter for discoverable type {TypeName} (slowish).", typeof(T).FullName);
|
||||
_logger.LogDebug("Running a non-cached, filter for discoverable type {TypeName} (slowish).", typeof(T).FullName);
|
||||
|
||||
// filter the cached discovered types (and maybe cache the result)
|
||||
return GetTypesInternal(
|
||||
@@ -525,7 +527,7 @@ namespace Umbraco.Core.Composing
|
||||
// if not IDiscoverable, directly get types
|
||||
if (!typeof(IDiscoverable).IsAssignableFrom(typeof(T)))
|
||||
{
|
||||
_logger.Debug<TypeLoader>("Running a full, " + (cache ? "" : "non-") + "cached, scan for non-discoverable type {TypeName} / attribute {AttributeName} (slow).", typeof(T).FullName, typeof(TAttribute).FullName);
|
||||
_logger.LogDebug("Running a full, " + (cache ? "" : "non-") + "cached, scan for non-discoverable type {TypeName} / attribute {AttributeName} (slow).", typeof(T).FullName, typeof(TAttribute).FullName);
|
||||
|
||||
return GetTypesInternal(
|
||||
typeof(T), typeof(TAttribute),
|
||||
@@ -543,7 +545,7 @@ namespace Umbraco.Core.Composing
|
||||
|
||||
// warn
|
||||
if (!cache)
|
||||
_logger.Debug<TypeLoader>("Running a non-cached, filter for discoverable type {TypeName} / attribute {AttributeName} (slowish).", typeof(T).FullName, typeof(TAttribute).FullName);
|
||||
_logger.LogDebug("Running a non-cached, filter for discoverable type {TypeName} / attribute {AttributeName} (slowish).", typeof(T).FullName, typeof(TAttribute).FullName);
|
||||
|
||||
// filter the cached discovered types (and maybe cache the result)
|
||||
return GetTypesInternal(
|
||||
@@ -573,7 +575,7 @@ namespace Umbraco.Core.Composing
|
||||
cache &= specificAssemblies == null;
|
||||
|
||||
if (!cache)
|
||||
_logger.Debug<TypeLoader>("Running a full, non-cached, scan for types / attribute {AttributeName} (slow).", typeof(TAttribute).FullName);
|
||||
_logger.LogDebug("Running a full, non-cached, scan for types / attribute {AttributeName} (slow).", typeof(TAttribute).FullName);
|
||||
|
||||
return GetTypesInternal(
|
||||
typeof (object), typeof (TAttribute),
|
||||
@@ -596,7 +598,7 @@ namespace Umbraco.Core.Composing
|
||||
var name = GetName(baseType, attributeType);
|
||||
|
||||
lock (_locko)
|
||||
using (_logger.DebugDuration<TypeLoader>(
|
||||
using (_profilingLogger.DebugDuration<TypeLoader>(
|
||||
"Getting " + name,
|
||||
"Got " + name)) // cannot contain typesFound.Count as it's evaluated before the find
|
||||
{
|
||||
@@ -629,7 +631,7 @@ namespace Umbraco.Core.Composing
|
||||
if (typeList != null)
|
||||
{
|
||||
// need to put some logging here to try to figure out why this is happening: http://issues.umbraco.org/issue/U4-3505
|
||||
_logger.Debug<TypeLoader>("Getting {TypeName}: found a cached type list.", GetName(baseType, attributeType));
|
||||
_logger.LogDebug("Getting {TypeName}: found a cached type list.", GetName(baseType, attributeType));
|
||||
return typeList.Types;
|
||||
}
|
||||
|
||||
@@ -645,7 +647,7 @@ namespace Umbraco.Core.Composing
|
||||
// report (only once) and scan and update the cache file
|
||||
if (_reportedChange == false)
|
||||
{
|
||||
_logger.Debug<TypeLoader>("Assemblies changes detected, need to rescan everything.");
|
||||
_logger.LogDebug("Assemblies changes detected, need to rescan everything.");
|
||||
_reportedChange = true;
|
||||
}
|
||||
}
|
||||
@@ -660,7 +662,7 @@ namespace Umbraco.Core.Composing
|
||||
// so in this instance there will never be a result.
|
||||
if (cacheResult.Exception is CachedTypeNotFoundInFileException || cacheResult.Success == false)
|
||||
{
|
||||
_logger.Debug<TypeLoader>("Getting {TypeName}: failed to load from cache file, must scan assemblies.", GetName(baseType, attributeType));
|
||||
_logger.LogDebug("Getting {TypeName}: failed to load from cache file, must scan assemblies.", GetName(baseType, attributeType));
|
||||
scan = true;
|
||||
}
|
||||
else
|
||||
@@ -674,7 +676,7 @@ namespace Umbraco.Core.Composing
|
||||
else
|
||||
{
|
||||
// in case of any exception, we have to exit, and revert to scanning
|
||||
_logger.LogWarning<TypeLoader>("Getting {TypeName}: failed to load cache file type {CacheType}, reverting to scanning assemblies.", GetName(baseType, attributeType), type);
|
||||
_logger.LogWarning("Getting {TypeName}: failed to load cache file type {CacheType}, reverting to scanning assemblies.", GetName(baseType, attributeType), type);
|
||||
scan = true;
|
||||
break;
|
||||
}
|
||||
@@ -682,7 +684,7 @@ namespace Umbraco.Core.Composing
|
||||
|
||||
if (scan == false)
|
||||
{
|
||||
_logger.Debug<TypeLoader>("Getting {TypeName}: loaded types from cache file.", GetName(baseType, attributeType));
|
||||
_logger.LogDebug("Getting {TypeName}: loaded types from cache file.", GetName(baseType, attributeType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -690,7 +692,7 @@ namespace Umbraco.Core.Composing
|
||||
if (scan)
|
||||
{
|
||||
// either we had to scan, or we could not get the types from the cache file - scan now
|
||||
_logger.Debug<TypeLoader>("Getting {TypeName}: " + action + ".", GetName(baseType, attributeType));
|
||||
_logger.LogDebug("Getting {TypeName}: " + action + ".", GetName(baseType, attributeType));
|
||||
|
||||
foreach (var t in finder())
|
||||
typeList.Add(t);
|
||||
@@ -708,11 +710,11 @@ namespace Umbraco.Core.Composing
|
||||
UpdateCache();
|
||||
}
|
||||
|
||||
_logger.Debug<TypeLoader>("Got {TypeName}, caching ({CacheType}).", GetName(baseType, attributeType), added.ToString().ToLowerInvariant());
|
||||
_logger.LogDebug("Got {TypeName}, caching ({CacheType}).", GetName(baseType, attributeType), added.ToString().ToLowerInvariant());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug<TypeLoader>("Got {TypeName}.", GetName(baseType, attributeType));
|
||||
_logger.LogDebug("Got {TypeName}.", GetName(baseType, attributeType));
|
||||
}
|
||||
|
||||
return typeList.Types;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Web.Routing
|
||||
private readonly IContentLastChanceFinder _contentLastChanceFinder;
|
||||
private readonly IProfilingLogger _profilingLogger;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<PublishedRouter> _logger;
|
||||
private readonly IPublishedUrlProvider _publishedUrlProvider;
|
||||
private readonly IRequestAccessor _requestAccessor;
|
||||
private readonly IPublishedValueFallback _publishedValueFallback;
|
||||
@@ -41,6 +41,7 @@ namespace Umbraco.Web.Routing
|
||||
IContentLastChanceFinder contentLastChanceFinder,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IProfilingLogger proflog,
|
||||
ILogger<PublishedRouter> logger,
|
||||
IPublishedUrlProvider publishedUrlProvider,
|
||||
IRequestAccessor requestAccessor,
|
||||
IPublishedValueFallback publishedValueFallback,
|
||||
@@ -54,7 +55,7 @@ namespace Umbraco.Web.Routing
|
||||
_contentLastChanceFinder = contentLastChanceFinder ?? throw new ArgumentNullException(nameof(contentLastChanceFinder));
|
||||
_profilingLogger = proflog ?? throw new ArgumentNullException(nameof(proflog));
|
||||
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
|
||||
_logger = proflog;
|
||||
_logger = logger;
|
||||
_publishedUrlProvider = publishedUrlProvider;
|
||||
_requestAccessor = requestAccessor;
|
||||
_publishedValueFallback = publishedValueFallback;
|
||||
@@ -247,7 +248,7 @@ namespace Umbraco.Web.Routing
|
||||
|
||||
// note - we are not handling schemes nor ports here.
|
||||
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}Uri={RequestUri}", tracePrefix, request.Uri);
|
||||
_logger.LogDebug("{TracePrefix}Uri={RequestUri}", tracePrefix, request.Uri);
|
||||
|
||||
var domainsCache = request.UmbracoContext.PublishedSnapshot.Domains;
|
||||
var domains = domainsCache.GetAll(includeWildcards: false).ToList();
|
||||
@@ -284,7 +285,7 @@ namespace Umbraco.Web.Routing
|
||||
if (domainAndUri != null)
|
||||
{
|
||||
// matching an existing domain
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}Matches domain={Domain}, rootId={RootContentId}, culture={Culture}", tracePrefix, domainAndUri.Name, domainAndUri.ContentId, domainAndUri.Culture);
|
||||
_logger.LogDebug("{TracePrefix}Matches domain={Domain}, rootId={RootContentId}, culture={Culture}", tracePrefix, domainAndUri.Name, domainAndUri.ContentId, domainAndUri.Culture);
|
||||
|
||||
request.Domain = domainAndUri;
|
||||
request.Culture = domainAndUri.Culture;
|
||||
@@ -299,12 +300,12 @@ namespace Umbraco.Web.Routing
|
||||
else
|
||||
{
|
||||
// not matching any existing domain
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}Matches no domain", tracePrefix);
|
||||
_logger.LogDebug("{TracePrefix}Matches no domain", tracePrefix);
|
||||
|
||||
request.Culture = defaultCulture == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultCulture);
|
||||
}
|
||||
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}Culture={CultureName}", tracePrefix, request.Culture.Name);
|
||||
_logger.LogDebug("{TracePrefix}Culture={CultureName}", tracePrefix, request.Culture.Name);
|
||||
|
||||
return request.Domain != null;
|
||||
}
|
||||
@@ -320,7 +321,7 @@ namespace Umbraco.Web.Routing
|
||||
return;
|
||||
|
||||
var nodePath = request.PublishedContent.Path;
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}Path={NodePath}", tracePrefix, nodePath);
|
||||
_logger.LogDebug("{TracePrefix}Path={NodePath}", tracePrefix, nodePath);
|
||||
var rootNodeId = request.HasDomain ? request.Domain.ContentId : (int?)null;
|
||||
var domain = DomainUtilities.FindWildcardDomainInPath(request.UmbracoContext.PublishedSnapshot.Domains.GetAll(true), nodePath, rootNodeId);
|
||||
|
||||
@@ -328,11 +329,11 @@ namespace Umbraco.Web.Routing
|
||||
if (domain != null)
|
||||
{
|
||||
request.Culture = domain.Culture;
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}Got domain on node {DomainContentId}, set culture to {CultureName}", tracePrefix, domain.ContentId, request.Culture.Name);
|
||||
_logger.LogDebug("{TracePrefix}Got domain on node {DomainContentId}, set culture to {CultureName}", tracePrefix, domain.ContentId, request.Culture.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("{TracePrefix}No match.", tracePrefix);
|
||||
_logger.LogDebug("{TracePrefix}No match.", tracePrefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +375,7 @@ namespace Umbraco.Web.Routing
|
||||
/// <returns>A value indicating whether a document and template were found.</returns>
|
||||
private void FindPublishedContentAndTemplate(IPublishedRequest request)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("FindPublishedContentAndTemplate: Path={UriAbsolutePath}", request.Uri.AbsolutePath);
|
||||
_logger.LogDebug("FindPublishedContentAndTemplate: Path={UriAbsolutePath}", request.Uri.AbsolutePath);
|
||||
|
||||
// run the document finders
|
||||
FindPublishedContent(request);
|
||||
@@ -417,7 +418,7 @@ namespace Umbraco.Web.Routing
|
||||
//iterate but return on first one that finds it
|
||||
var found = _contentFinders.Any(finder =>
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("Finder {ContentFinderType}", finder.GetType().FullName);
|
||||
_logger.LogDebug("Finder {ContentFinderType}", finder.GetType().FullName);
|
||||
return finder.TryFindContent(request);
|
||||
});
|
||||
}
|
||||
@@ -441,22 +442,22 @@ namespace Umbraco.Web.Routing
|
||||
const int maxLoop = 8;
|
||||
do
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("HandlePublishedContent: Loop {LoopCounter}", i);
|
||||
_logger.LogDebug("HandlePublishedContent: Loop {LoopCounter}", i);
|
||||
|
||||
// handle not found
|
||||
if (request.HasPublishedContent == false)
|
||||
{
|
||||
request.Is404 = true;
|
||||
_logger.Debug<PublishedRouter>("HandlePublishedContent: No document, try last chance lookup");
|
||||
_logger.LogDebug("HandlePublishedContent: No document, try last chance lookup");
|
||||
|
||||
// if it fails then give up, there isn't much more that we can do
|
||||
if (_contentLastChanceFinder.TryFindContent(request) == false)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("HandlePublishedContent: Failed to find a document, give up");
|
||||
_logger.LogDebug("HandlePublishedContent: Failed to find a document, give up");
|
||||
break;
|
||||
}
|
||||
|
||||
_logger.Debug<PublishedRouter>("HandlePublishedContent: Found a document");
|
||||
_logger.LogDebug("HandlePublishedContent: Found a document");
|
||||
}
|
||||
|
||||
// follow internal redirects as long as it's not running out of control ie infinite loop of some sort
|
||||
@@ -478,11 +479,11 @@ namespace Umbraco.Web.Routing
|
||||
|
||||
if (i == maxLoop || j == maxLoop)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("HandlePublishedContent: Looks like we are running into an infinite loop, abort");
|
||||
_logger.LogDebug("HandlePublishedContent: Looks like we are running into an infinite loop, abort");
|
||||
request.PublishedContent = null;
|
||||
}
|
||||
|
||||
_logger.Debug<PublishedRouter>("HandlePublishedContent: End");
|
||||
_logger.LogDebug("HandlePublishedContent: End");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -527,25 +528,25 @@ namespace Umbraco.Web.Routing
|
||||
if (valid == false)
|
||||
{
|
||||
// bad redirect - log and display the current page (legacy behavior)
|
||||
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Failed to redirect to id={InternalRedirectId}: value is not an int nor a GuidUdi.",
|
||||
_logger.LogDebug("FollowInternalRedirects: Failed to redirect to id={InternalRedirectId}: value is not an int nor a GuidUdi.",
|
||||
request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).GetSourceValue());
|
||||
}
|
||||
|
||||
if (internalRedirectNode == null)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Failed to redirect to id={InternalRedirectId}: no such published document.",
|
||||
_logger.LogDebug("FollowInternalRedirects: Failed to redirect to id={InternalRedirectId}: no such published document.",
|
||||
request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).GetSourceValue());
|
||||
}
|
||||
else if (internalRedirectId == request.PublishedContent.Id)
|
||||
{
|
||||
// redirect to self
|
||||
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Redirecting to self, ignore");
|
||||
_logger.LogDebug("FollowInternalRedirects: Redirecting to self, ignore");
|
||||
}
|
||||
else
|
||||
{
|
||||
request.SetInternalRedirectPublishedContent(internalRedirectNode); // don't use .PublishedContent here
|
||||
redirect = true;
|
||||
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Redirecting to id={InternalRedirectId}", internalRedirectId);
|
||||
_logger.LogDebug("FollowInternalRedirects: Redirecting to id={InternalRedirectId}", internalRedirectId);
|
||||
}
|
||||
|
||||
return redirect;
|
||||
@@ -566,35 +567,35 @@ namespace Umbraco.Web.Routing
|
||||
|
||||
if (publicAccessAttempt)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Page is protected, check for access");
|
||||
_logger.LogDebug("EnsurePublishedContentAccess: Page is protected, check for access");
|
||||
|
||||
var status = _publicAccessChecker.HasMemberAccessToContent(request.PublishedContent.Id);
|
||||
switch (status)
|
||||
{
|
||||
case PublicAccessStatus.NotLoggedIn:
|
||||
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Not logged in, redirect to login page");
|
||||
_logger.LogDebug("EnsurePublishedContentAccess: Not logged in, redirect to login page");
|
||||
SetPublishedContentAsOtherPage(request, publicAccessAttempt.Result.LoginNodeId);
|
||||
break;
|
||||
case PublicAccessStatus.AccessDenied:
|
||||
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Current member has not access, redirect to error page");
|
||||
_logger.LogDebug("EnsurePublishedContentAccess: Current member has not access, redirect to error page");
|
||||
SetPublishedContentAsOtherPage(request, publicAccessAttempt.Result.NoAccessNodeId);
|
||||
break;
|
||||
case PublicAccessStatus.LockedOut:
|
||||
_logger.Debug<PublishedRouter>("Current member is locked out, redirect to error page");
|
||||
_logger.LogDebug("Current member is locked out, redirect to error page");
|
||||
SetPublishedContentAsOtherPage(request, publicAccessAttempt.Result.NoAccessNodeId);
|
||||
break;
|
||||
case PublicAccessStatus.NotApproved:
|
||||
_logger.Debug<PublishedRouter>("Current member is unapproved, redirect to error page");
|
||||
_logger.LogDebug("Current member is unapproved, redirect to error page");
|
||||
SetPublishedContentAsOtherPage(request, publicAccessAttempt.Result.NoAccessNodeId);
|
||||
break;
|
||||
case PublicAccessStatus.AccessAccepted:
|
||||
_logger.Debug<PublishedRouter>("Current member has access");
|
||||
_logger.LogDebug("Current member has access");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Page is not protected");
|
||||
_logger.LogDebug("EnsurePublishedContentAccess: Page is not protected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +638,7 @@ namespace Umbraco.Web.Routing
|
||||
|
||||
if (request.HasTemplate)
|
||||
{
|
||||
_logger.Debug<IPublishedRequest>("FindTemplate: Has a template already, and no alternate template.");
|
||||
_logger.LogDebug("FindTemplate: Has a template already, and no alternate template.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -659,8 +660,8 @@ namespace Umbraco.Web.Routing
|
||||
// ignore if the alias does not match - just trace
|
||||
|
||||
if (request.HasTemplate)
|
||||
_logger.Debug<PublishedRouter>("FindTemplate: Has a template already, but also an alternative template.");
|
||||
_logger.Debug<PublishedRouter>("FindTemplate: Look for alternative template alias={AltTemplate}", altTemplate);
|
||||
_logger.LogDebug("FindTemplate: Has a template already, but also an alternative template.");
|
||||
_logger.LogDebug("FindTemplate: Look for alternative template alias={AltTemplate}", altTemplate);
|
||||
|
||||
// IsAllowedTemplate deals both with DisableAlternativeTemplates and ValidateAlternativeTemplates settings
|
||||
if (request.PublishedContent.IsAllowedTemplate(
|
||||
@@ -676,16 +677,16 @@ namespace Umbraco.Web.Routing
|
||||
if (template != null)
|
||||
{
|
||||
request.TemplateModel = template;
|
||||
_logger.Debug<PublishedRouter>("FindTemplate: Got alternative template id={TemplateId} alias={TemplateAlias}", template.Id, template.Alias);
|
||||
_logger.LogDebug("FindTemplate: Got alternative template id={TemplateId} alias={TemplateAlias}", template.Id, template.Alias);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("FindTemplate: The alternative template with alias={AltTemplate} does not exist, ignoring.", altTemplate);
|
||||
_logger.LogDebug("FindTemplate: The alternative template with alias={AltTemplate} does not exist, ignoring.", altTemplate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning<PublishedRouter>("FindTemplate: Alternative template {TemplateAlias} is not allowed on node {NodeId}, ignoring.", altTemplate, request.PublishedContent.Id);
|
||||
_logger.LogWarning("FindTemplate: Alternative template {TemplateAlias} is not allowed on node {NodeId}, ignoring.", altTemplate, request.PublishedContent.Id);
|
||||
|
||||
// no allowed, back to default
|
||||
var templateId = request.PublishedContent.TemplateId;
|
||||
@@ -695,7 +696,7 @@ namespace Umbraco.Web.Routing
|
||||
|
||||
if (request.HasTemplate == false)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("FindTemplate: No template was found.");
|
||||
_logger.LogDebug("FindTemplate: No template was found.");
|
||||
|
||||
// initial idea was: if we're not already 404 and UmbracoSettings.HandleMissingTemplateAs404 is true
|
||||
// then reset _pcr.Document to null to force a 404.
|
||||
@@ -708,7 +709,7 @@ namespace Umbraco.Web.Routing
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("FindTemplate: Running with template id={TemplateId} alias={TemplateAlias}", request.TemplateModel.Id, request.TemplateModel.Alias);
|
||||
_logger.LogDebug("FindTemplate: Running with template id={TemplateId} alias={TemplateAlias}", request.TemplateModel.Id, request.TemplateModel.Alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,11 +717,11 @@ namespace Umbraco.Web.Routing
|
||||
{
|
||||
if (templateId.HasValue == false || templateId.Value == default)
|
||||
{
|
||||
_logger.Debug<PublishedRouter>("GetTemplateModel: No template.");
|
||||
_logger.LogDebug("GetTemplateModel: No template.");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.Debug<PublishedRouter>("GetTemplateModel: Get template id={TemplateId}", templateId);
|
||||
_logger.LogDebug("GetTemplateModel: Get template id={TemplateId}", templateId);
|
||||
|
||||
if (templateId == null)
|
||||
throw new InvalidOperationException("The template is not set, the page cannot render.");
|
||||
@@ -728,7 +729,7 @@ namespace Umbraco.Web.Routing
|
||||
var template = _fileService.GetTemplate(templateId.Value);
|
||||
if (template == null)
|
||||
throw new InvalidOperationException("The template with Id " + templateId + " does not exist, the page cannot render.");
|
||||
_logger.Debug<PublishedRouter>("GetTemplateModel: Got template id={TemplateId} alias={TemplateAlias}", template.Id, template.Alias);
|
||||
_logger.LogDebug("GetTemplateModel: Got template id={TemplateId} alias={TemplateAlias}", template.Id, template.Alias);
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user