From 58e59e2fca8d9d672d45dee661e11b9a7616dc19 Mon Sep 17 00:00:00 2001 From: HermesSbicego-Laser Date: Wed, 19 Oct 2016 16:30:12 +0200 Subject: [PATCH 1/2] - added EventHandler in order to partecipate in cachekey generation --- .../Filters/OutputCacheFilter.cs | 13 ++++++++++++- .../Orchard.OutputCache/ICachingEventHandler.cs | 12 ++++++++++++ .../Orchard.OutputCache/Orchard.OutputCache.csproj | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/Orchard.Web/Modules/Orchard.OutputCache/ICachingEventHandler.cs diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index 548012e6b..8df84b69f 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -41,6 +41,7 @@ namespace Orchard.OutputCache.Filters { private readonly ICacheService _cacheService; private readonly ISignals _signals; private readonly ShellSettings _shellSettings; + private readonly ICachingEventHandler _chachingEvents; private bool _isDisposed = false; public ILogger Logger { get; set; } @@ -55,7 +56,8 @@ namespace Orchard.OutputCache.Filters { IClock clock, ICacheService cacheService, ISignals signals, - ShellSettings shellSettings) { + ShellSettings shellSettings, + ICachingEventHandler chachingEvents) { _cacheManager = cacheManager; _cacheStorageProvider = cacheStorageProvider; @@ -67,6 +69,7 @@ namespace Orchard.OutputCache.Filters { _cacheService = cacheService; _signals = signals; _shellSettings = shellSettings; + _chachingEvents = chachingEvents; Logger = NullLogger.Instance; } @@ -610,6 +613,14 @@ namespace Orchard.OutputCache.Filters { } } + //make CacheKey morphable by external modules + try { + keyBuilder = _chachingEvents.ParticipateInCacheKey(keyBuilder); + } catch (UnauthorizedAccessException ex) { + throw new UnauthorizedAccessException(); + } catch { } + + return keyBuilder.ToString(); } diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/ICachingEventHandler.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/ICachingEventHandler.cs new file mode 100644 index 000000000..6e9aebf5a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/ICachingEventHandler.cs @@ -0,0 +1,12 @@ +using Orchard.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; + +namespace Orchard.OutputCache { + public interface ICachingEventHandler : IEventHandler { + StringBuilder ParticipateInCacheKey(StringBuilder key); + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj b/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj index a3a7fa74c..9a4520288 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj @@ -103,6 +103,7 @@ + From 350cbbd183414a41cf0886967c918d9482e47fea Mon Sep 17 00:00:00 2001 From: HermesSbicego-Laser Date: Wed, 19 Oct 2016 17:40:58 +0200 Subject: [PATCH 2/2] - typo chaching > caching --- .../Orchard.OutputCache/Filters/OutputCacheFilter.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index 8df84b69f..b8ddff839 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -41,7 +41,7 @@ namespace Orchard.OutputCache.Filters { private readonly ICacheService _cacheService; private readonly ISignals _signals; private readonly ShellSettings _shellSettings; - private readonly ICachingEventHandler _chachingEvents; + private readonly ICachingEventHandler _cachingEvents; private bool _isDisposed = false; public ILogger Logger { get; set; } @@ -57,7 +57,7 @@ namespace Orchard.OutputCache.Filters { ICacheService cacheService, ISignals signals, ShellSettings shellSettings, - ICachingEventHandler chachingEvents) { + ICachingEventHandler cachingEvents) { _cacheManager = cacheManager; _cacheStorageProvider = cacheStorageProvider; @@ -69,7 +69,7 @@ namespace Orchard.OutputCache.Filters { _cacheService = cacheService; _signals = signals; _shellSettings = shellSettings; - _chachingEvents = chachingEvents; + _cachingEvents = cachingEvents; Logger = NullLogger.Instance; } @@ -615,7 +615,7 @@ namespace Orchard.OutputCache.Filters { //make CacheKey morphable by external modules try { - keyBuilder = _chachingEvents.ParticipateInCacheKey(keyBuilder); + keyBuilder = _cachingEvents.ParticipateInCacheKey(keyBuilder); } catch (UnauthorizedAccessException ex) { throw new UnauthorizedAccessException(); } catch { }