https://github.com/umbraco/Umbraco-CMS/issues/9813 - Fixed issue with configuration value cached, even that the dashboard was updating its value.

This commit is contained in:
Bjarke Berg
2021-02-15 08:08:52 +01:00
parent aeae2fcfd2
commit 801c565bd5
2 changed files with 23 additions and 25 deletions

View File

@@ -5,7 +5,6 @@ using Microsoft.Extensions.Options;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
@@ -26,14 +25,14 @@ namespace Umbraco.Web.Routing
{
private const string _eventStateKey = "Umbraco.Web.Redirects.RedirectTrackingEventHandler";
private readonly WebRoutingSettings _webRoutingSettings;
private readonly IOptionsMonitor<WebRoutingSettings> _webRoutingSettings;
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IRedirectUrlService _redirectUrlService;
private readonly IVariationContextAccessor _variationContextAccessor;
public RedirectTrackingComponent(IOptions<WebRoutingSettings> webRoutingSettings, IPublishedSnapshotAccessor publishedSnapshotAccessor, IRedirectUrlService redirectUrlService, IVariationContextAccessor variationContextAccessor)
public RedirectTrackingComponent(IOptionsMonitor<WebRoutingSettings> webRoutingSettings, IPublishedSnapshotAccessor publishedSnapshotAccessor, IRedirectUrlService redirectUrlService, IVariationContextAccessor variationContextAccessor)
{
_webRoutingSettings = webRoutingSettings.Value;
_webRoutingSettings = webRoutingSettings;
_publishedSnapshotAccessor = publishedSnapshotAccessor;
_redirectUrlService = redirectUrlService;
_variationContextAccessor = variationContextAccessor;
@@ -65,7 +64,7 @@ namespace Umbraco.Web.Routing
private void ContentService_Publishing(IContentService sender, PublishEventArgs<IContent> args)
{
// don't let the event handlers kick in if Redirect Tracking is turned off in the config
if (_webRoutingSettings.DisableRedirectUrlTracking) return;
if (_webRoutingSettings.CurrentValue.DisableRedirectUrlTracking) return;
var oldRoutes = GetOldRoutes(args.EventState);
foreach (var entity in args.PublishedEntities)
@@ -77,7 +76,7 @@ namespace Umbraco.Web.Routing
private void ContentService_Published(IContentService sender, ContentPublishedEventArgs args)
{
// don't let the event handlers kick in if Redirect Tracking is turned off in the config
if (_webRoutingSettings.DisableRedirectUrlTracking) return;
if (_webRoutingSettings.CurrentValue.DisableRedirectUrlTracking) return;
var oldRoutes = GetOldRoutes(args.EventState);
CreateRedirects(oldRoutes);
@@ -86,7 +85,7 @@ namespace Umbraco.Web.Routing
private void ContentService_Moving(IContentService sender, MoveEventArgs<IContent> args)
{
// don't let the event handlers kick in if Redirect Tracking is turned off in the config
if (_webRoutingSettings.DisableRedirectUrlTracking) return;
if (_webRoutingSettings.CurrentValue.DisableRedirectUrlTracking) return;
var oldRoutes = GetOldRoutes(args.EventState);
foreach (var info in args.MoveInfoCollection)
@@ -98,7 +97,7 @@ namespace Umbraco.Web.Routing
private void ContentService_Moved(IContentService sender, MoveEventArgs<IContent> args)
{
// don't let the event handlers kick in if Redirect Tracking is turned off in the config
if (_webRoutingSettings.DisableRedirectUrlTracking) return;
if (_webRoutingSettings.CurrentValue.DisableRedirectUrlTracking) return;
var oldRoutes = GetOldRoutes(args.EventState);
CreateRedirects(oldRoutes);