Merge pull request #1511 from umbraco/temp-U4-8992
U4-8992 - update content and media xml caches when upgrading from bef…
This commit is contained in:
@@ -128,8 +128,14 @@ namespace Umbraco.Core.Events
|
||||
get { return TargetSemVersion.GetVersion(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the origin version of the migration, i.e. the one that is currently installed.
|
||||
/// </summary>
|
||||
public SemVersion ConfiguredSemVersion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target version of the migration.
|
||||
/// </summary>
|
||||
public SemVersion TargetSemVersion { get; private set; }
|
||||
|
||||
public string ProductName { get; private set; }
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Web.Strategies.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// This will execute after upgrading to rebuild the xml cache
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
public class RebuildMediaXmlCacheAfterUpgrade : MigrationStartupHander
|
||||
{
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
if (e.ProductName != GlobalSettings.UmbracoMigrationName) return;
|
||||
|
||||
var target70 = new Version(7, 0, 0);
|
||||
|
||||
if (e.ConfiguredVersion <= target70)
|
||||
{
|
||||
var mediasvc = (MediaService)ApplicationContext.Current.Services.MediaService;
|
||||
mediasvc.RebuildXmlStructures();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using umbraco;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Services;
|
||||
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
|
||||
|
||||
namespace Umbraco.Web.Strategies.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// Rebuilds the Xml caches after upgrading.
|
||||
/// This will execute after upgrading to rebuild the xml cache
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>This cannot execute as part of a DB migration since it needs access to services and repositories.</para>
|
||||
/// <para>Executes for:
|
||||
/// - Media Xml : if current is less than, or equal to, 7.0.0 (superceeded by the next rule)
|
||||
/// - Media & Content Xml : if current is less than, or equal to, 7.3.0 - because 7.3.0 adds .Key to cached items
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public class RebuildXmlCachesAfterUpgrade : MigrationStartupHander
|
||||
{
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
if (e.ProductName != GlobalSettings.UmbracoMigrationName) return;
|
||||
|
||||
var v730 = new Semver.SemVersion(new Version(7, 3, 0));
|
||||
|
||||
var doMedia = e.ConfiguredSemVersion < v730;
|
||||
var doContent = e.ConfiguredSemVersion < v730;
|
||||
|
||||
if (doMedia)
|
||||
{
|
||||
var mediaService = (MediaService) ApplicationContext.Current.Services.MediaService;
|
||||
mediaService.RebuildXmlStructures();
|
||||
|
||||
// note: not re-indexing medias?
|
||||
}
|
||||
|
||||
if (doContent)
|
||||
{
|
||||
// rebuild Xml in database
|
||||
var contentService = (ContentService) ApplicationContext.Current.Services.ContentService;
|
||||
contentService.RebuildXmlStructures();
|
||||
|
||||
// refresh the Xml cache
|
||||
content.Instance.RefreshContentFromDatabase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -914,7 +914,7 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\JavaScript\ServerVariablesParser.cs" />
|
||||
<Compile Include="Strategies\Migrations\RebuildMediaXmlCacheAfterUpgrade.cs" />
|
||||
<Compile Include="Strategies\Migrations\RebuildXmlCachesAfterUpgrade.cs" />
|
||||
<Compile Include="Strategies\PublicAccessEventHandler.cs" />
|
||||
<Compile Include="UI\Bundles\JsApplicationLib.cs" />
|
||||
<Compile Include="UI\Bundles\JsJQueryCore.cs" />
|
||||
|
||||
Reference in New Issue
Block a user