From 59a9f0bf03b339ebc6aec260bba8e2ecb8670dc4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 17 Oct 2016 14:34:37 -0700 Subject: [PATCH 1/2] Fixing SQL exception during automatic migrations in PostgreSql Fixes #6783 Fixes #7323 --- .../Data/Migration/AutomaticDataMigrations.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Orchard/Data/Migration/AutomaticDataMigrations.cs b/src/Orchard/Data/Migration/AutomaticDataMigrations.cs index fb5a3456c..2c936313a 100644 --- a/src/Orchard/Data/Migration/AutomaticDataMigrations.cs +++ b/src/Orchard/Data/Migration/AutomaticDataMigrations.cs @@ -80,12 +80,25 @@ namespace Orchard.Data.Migration { /// /// This ensures that the framework migrations have run for the distributed locking feature, as existing Orchard installations will not have the required tables when upgrading. /// - private void EnsureDistributedLockSchemaExists() { + private void EnsureDistributedLockSchemaExists() + { // Ensure the distributed lock record schema exists. var schemaBuilder = new SchemaBuilder(_dataMigrationInterpreter); var distributedLockSchemaBuilder = new DistributedLockSchemaBuilder(_shellSettings, schemaBuilder); - if (distributedLockSchemaBuilder.EnsureSchema()) + if (!distributedLockSchemaBuilder.SchemaExists()) + { + + // Workaround to avoid some Transaction issue for PostgreSQL. + if (_shellSettings.DataProvider.Equals("PostgreSql", StringComparison.OrdinalIgnoreCase)) + { + _transactionManager.RequireNew(); + distributedLockSchemaBuilder.CreateSchema(); + return; + } + + distributedLockSchemaBuilder.CreateSchema(); _transactionManager.RequireNew(); + } } } } From 58e59e2fca8d9d672d45dee661e11b9a7616dc19 Mon Sep 17 00:00:00 2001 From: HermesSbicego-Laser Date: Wed, 19 Oct 2016 16:30:12 +0200 Subject: [PATCH 2/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 @@ +