mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 19:44:02 +08:00
Fixing intermittent exception
IAuthorizer was called lazyly from a ISingletonDependency. Should use Work<> instead --HG-- branch : 1.x
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Threading;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Events;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
@@ -11,14 +12,14 @@ using Orchard.UI.Notify;
|
||||
namespace Orchard.Exceptions {
|
||||
public class DefaultExceptionPolicy : IExceptionPolicy {
|
||||
private readonly INotifier _notifier;
|
||||
private readonly Lazy<IAuthorizer> _authorizer;
|
||||
private readonly Work<IAuthorizer> _authorizer;
|
||||
|
||||
public DefaultExceptionPolicy() {
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public DefaultExceptionPolicy(INotifier notifier, Lazy<IAuthorizer> authorizer) {
|
||||
public DefaultExceptionPolicy(INotifier notifier, Work<IAuthorizer> authorizer) {
|
||||
_notifier = notifier;
|
||||
_authorizer = authorizer;
|
||||
Logger = NullLogger.Instance;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.ServiceModel.Activation;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
@@ -10,17 +9,17 @@ namespace Orchard.Mvc.Routes {
|
||||
public class RoutePublisher : IRoutePublisher {
|
||||
private readonly RouteCollection _routeCollection;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ILifetimeScope _shellLifetimeScope;
|
||||
private readonly WorkContextAccessor _workContextAccessor;
|
||||
private readonly IRunningShellTable _runningShellTable;
|
||||
|
||||
public RoutePublisher(
|
||||
RouteCollection routeCollection,
|
||||
ShellSettings shellSettings,
|
||||
ILifetimeScope shellLifetimeScope,
|
||||
WorkContextAccessor workContextAccessor,
|
||||
IRunningShellTable runningShellTable) {
|
||||
_routeCollection = routeCollection;
|
||||
_shellSettings = shellSettings;
|
||||
_shellLifetimeScope = shellLifetimeScope;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_runningShellTable = runningShellTable;
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ namespace Orchard.Mvc.Routes {
|
||||
|
||||
// new routes are added
|
||||
foreach (var routeDescriptor in routesArray) {
|
||||
ShellRoute shellRoute = new ShellRoute(routeDescriptor.Route, _shellSettings, _shellLifetimeScope, _runningShellTable);
|
||||
var shellRoute = new ShellRoute(routeDescriptor.Route, _shellSettings, _workContextAccessor, _runningShellTable);
|
||||
_routeCollection.Add(routeDescriptor.Name, shellRoute);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.SessionState;
|
||||
using Autofac;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Mvc.Extensions;
|
||||
@@ -18,11 +17,11 @@ namespace Orchard.Mvc.Routes {
|
||||
private readonly IRunningShellTable _runningShellTable;
|
||||
private readonly UrlPrefix _urlPrefix;
|
||||
|
||||
public ShellRoute(RouteBase route, ShellSettings shellSettings, ILifetimeScope shellLifetimeScope, IRunningShellTable runningShellTable) {
|
||||
public ShellRoute(RouteBase route, ShellSettings shellSettings, WorkContextAccessor workContextAccessor, IRunningShellTable runningShellTable) {
|
||||
_route = route;
|
||||
_shellSettings = shellSettings;
|
||||
_runningShellTable = runningShellTable;
|
||||
_workContextAccessor = shellLifetimeScope.Resolve<IWorkContextAccessor>();
|
||||
_workContextAccessor = workContextAccessor;
|
||||
if (!string.IsNullOrEmpty(_shellSettings.RequestUrlPrefix))
|
||||
_urlPrefix = new UrlPrefix(_shellSettings.RequestUrlPrefix);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user