mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixing issue with fetching a theme and rendering shapes from a background thread.
This commit is contained in:
@@ -399,7 +399,8 @@ namespace Orchard.Core.Shapes {
|
||||
break;
|
||||
default:
|
||||
Debug.Assert(site.ResourceDebugMode == ResourceDebugMode.FromAppSetting, "Unknown ResourceDebugMode value.");
|
||||
debugMode = _httpContextAccessor.Value.Current().IsDebuggingEnabled;
|
||||
var context = _httpContextAccessor.Value.Current();
|
||||
debugMode = context != null && context.IsDebuggingEnabled;
|
||||
break;
|
||||
}
|
||||
var defaultSettings = new RequireSettings {
|
||||
@@ -408,7 +409,11 @@ namespace Orchard.Core.Shapes {
|
||||
Culture = _workContext.Value.CurrentCulture,
|
||||
};
|
||||
var requiredResources = _resourceManager.Value.BuildRequiredResources(resourceType);
|
||||
var appPath = _httpContextAccessor.Value.Current().Request.ApplicationPath;
|
||||
var httpContext = _httpContextAccessor.Value.Current();
|
||||
var appPath = httpContext == null || httpContext.Request == null
|
||||
? null
|
||||
: httpContext.Request.ApplicationPath;
|
||||
|
||||
foreach (var context in requiredResources.Where(r =>
|
||||
(includeLocation.HasValue ? r.Settings.Location == includeLocation.Value : true) &&
|
||||
(excludeLocation.HasValue ? r.Settings.Location != excludeLocation.Value : true))) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
|
||||
namespace Orchard.Themes
|
||||
{
|
||||
@@ -16,9 +17,12 @@ namespace Orchard.Themes
|
||||
|
||||
public Func<WorkContext, T> Get<T>(string name)
|
||||
{
|
||||
if (name == "CurrentTheme")
|
||||
{
|
||||
var currentTheme = _themeManager.GetRequestTheme(_httpContextAccessor.Current().Request.RequestContext);
|
||||
if (name == "CurrentTheme") {
|
||||
var context = _httpContextAccessor.Current();
|
||||
var currentTheme = context != null && context.Request != null
|
||||
? _themeManager.GetRequestTheme(context.Request.RequestContext)
|
||||
: null;
|
||||
|
||||
return ctx => (T)(object)currentTheme;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -204,7 +204,9 @@ namespace Orchard.UI.Resources {
|
||||
url = VirtualPathUtility.Combine(BasePath, url);
|
||||
}
|
||||
if (VirtualPathUtility.IsAppRelative(url)) {
|
||||
url = VirtualPathUtility.ToAbsolute(url, applicationPath);
|
||||
url = applicationPath != null
|
||||
? VirtualPathUtility.ToAbsolute(url, applicationPath)
|
||||
: VirtualPathUtility.ToAbsolute(url);
|
||||
}
|
||||
_urlResolveCache[settings] = url;
|
||||
return url;
|
||||
|
||||
Reference in New Issue
Block a user