mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#19082: Fixing exception when resolving BlogPartArchiveHandler from a singleton
Work Item: 19082 --HG-- branch : 1.x
This commit is contained in:
@@ -12,16 +12,15 @@ using Orchard.Data;
|
|||||||
namespace Orchard.Blogs.Handlers {
|
namespace Orchard.Blogs.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class BlogPartArchiveHandler : ContentHandler {
|
public class BlogPartArchiveHandler : ContentHandler {
|
||||||
private readonly WorkContext _workContext;
|
private readonly IWorkContextAccessor _workContextAccessor;
|
||||||
// contains the creation time of a blog part before it has been changed
|
// contains the creation time of a blog part before it has been changed
|
||||||
private readonly Dictionary<BlogPostPart, DateTime> _previousCreatedUtc = new Dictionary<BlogPostPart,DateTime>();
|
private readonly Dictionary<BlogPostPart, DateTime> _previousCreatedUtc = new Dictionary<BlogPostPart,DateTime>();
|
||||||
|
|
||||||
public BlogPartArchiveHandler(
|
public BlogPartArchiveHandler(
|
||||||
IRepository<BlogPartArchiveRecord> blogArchiveRepository,
|
IRepository<BlogPartArchiveRecord> blogArchiveRepository,
|
||||||
IBlogPostService blogPostService,
|
IBlogPostService blogPostService,
|
||||||
WorkContext workContext) {
|
IWorkContextAccessor workContextAccessor) {
|
||||||
|
_workContextAccessor = workContextAccessor;
|
||||||
_workContext = workContext;
|
|
||||||
|
|
||||||
OnVersioning<BlogPostPart>((context, bp1, bp2) => {
|
OnVersioning<BlogPostPart>((context, bp1, bp2) => {
|
||||||
var commonPart = bp1.As<CommonPart>();
|
var commonPart = bp1.As<CommonPart>();
|
||||||
@@ -44,7 +43,7 @@ namespace Orchard.Blogs.Handlers {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// get the time zone for the current request
|
// get the time zone for the current request
|
||||||
var timeZone = _workContext.CurrentTimeZone;
|
var timeZone = _workContextAccessor.GetContext().CurrentTimeZone;
|
||||||
|
|
||||||
var previousCreatedUtc = _previousCreatedUtc.ContainsKey(blogPostPart) ? _previousCreatedUtc[blogPostPart] : DateTime.MinValue;
|
var previousCreatedUtc = _previousCreatedUtc.ContainsKey(blogPostPart) ? _previousCreatedUtc[blogPostPart] : DateTime.MinValue;
|
||||||
previousCreatedUtc = TimeZoneInfo.ConvertTimeFromUtc(previousCreatedUtc, timeZone);
|
previousCreatedUtc = TimeZoneInfo.ConvertTimeFromUtc(previousCreatedUtc, timeZone);
|
||||||
|
|||||||
Reference in New Issue
Block a user