diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenZeroOne/RemoveCachedRecycleMediaXml.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenZeroOne/RemoveCachedRecycleMediaXml.cs deleted file mode 100644 index 53b2728728..0000000000 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenZeroOne/RemoveCachedRecycleMediaXml.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Umbraco.Core.Configuration; -using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Services; - -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenZeroOne -{ - /// - /// Due to this bug: http://issues.umbraco.org/issue/U4-3820 we need to remove the cached media - /// xml found in the cmsContentXml table for any media that has been recycled. - /// - [Migration("7.0.1", 1, GlobalSettings.UmbracoMigrationName)] - public class RemoveCachedRecycleMediaXml : MigrationBase - { - public override void Up() - { - //now that the controlId column is renamed and now a string we need to convert - if (Context == null || Context.Database == null) return; - - Execute.Code(database => - { - var mediasvc = (MediaService) ApplicationContext.Current.Services.MediaService; - mediasvc.RebuildXmlStructures(); - - return string.Empty; - }); - } - - public override void Down() - { - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/RemoveCachedRecycleMediaXml.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/RemoveCachedRecycleMediaXml.cs deleted file mode 100644 index d0945db957..0000000000 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/RemoveCachedRecycleMediaXml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Umbraco.Core.Configuration; -using Umbraco.Core.Services; - -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero -{ - /// - /// Due to this bug: http://issues.umbraco.org/issue/U4-3820 we need to remove the cached media - /// xml found in the cmsContentXml table for any media that has been recycled. - /// - [Migration("6.2.0", 1, GlobalSettings.UmbracoMigrationName)] - public class RemoveCachedRecycleMediaXml : MigrationBase - { - public override void Up() - { - //now that the controlId column is renamed and now a string we need to convert - if (Context == null || Context.Database == null) return; - - Execute.Code(database => - { - var mediasvc = (MediaService)ApplicationContext.Current.Services.MediaService; - mediasvc.RebuildXmlStructures(); - - return string.Empty; - }); - } - - public override void Down() - { - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 03a6db5371..880673ef6e 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -337,10 +337,8 @@ - - diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config index 460d8d47d7..4d1c76eacb 100644 --- a/src/Umbraco.Web.UI/config/trees.config +++ b/src/Umbraco.Web.UI/config/trees.config @@ -39,4 +39,5 @@ + \ No newline at end of file diff --git a/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs new file mode 100644 index 0000000000..72cf6c24ea --- /dev/null +++ b/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs @@ -0,0 +1,38 @@ +using System; +using Umbraco.Core; +using Umbraco.Core.Persistence.Migrations; +using Umbraco.Core.Services; +using umbraco.interfaces; + +namespace Umbraco.Web.Strategies.Migrations +{ + /// + /// This will execute after upgrading to rebuild the xml cache + /// + /// + /// This cannot execute as part of a db migration since we need access to the services/repos. + /// + /// This will execute for specific versions - + /// + /// * If current is less than or equal to 7.0.0 + /// + public class RebuildMediaXmlCacheAfterUpgrade : IApplicationStartupHandler + { + public RebuildMediaXmlCacheAfterUpgrade() + { + MigrationRunner.Migrated += MigrationRunner_Migrated; + } + + void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e) + { + var target70 = new Version(7, 0, 0); + + if (e.ConfiguredVersion <= target70) + { + var mediasvc = (MediaService)ApplicationContext.Current.Services.MediaService; + mediasvc.RebuildXmlStructures(); + } + + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index da421fbea5..e20819c7d1 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -405,6 +405,7 @@ +