diff --git a/src/Umbraco.Core/Constants-ObjectTypes.cs b/src/Umbraco.Core/Constants-ObjectTypes.cs
index 508b82e255..81bd66928d 100644
--- a/src/Umbraco.Core/Constants-ObjectTypes.cs
+++ b/src/Umbraco.Core/Constants-ObjectTypes.cs
@@ -1,4 +1,6 @@
-namespace Umbraco.Core
+using System;
+
+namespace Umbraco.Core
{
public static partial class Constants
{
@@ -70,8 +72,10 @@
///
/// Guid for a Stylesheet object.
///
- public const string Stylesheet = "9F68DA4F-A3A8-44C2-8226-DCBD125E4840";
+ [Obsolete("This no longer exists in the database")]
+ public const string Stylesheet = "9F68DA4F-A3A8-44C2-8226-DCBD125E4840";
+ [Obsolete("This no longer exists in the database")]
internal const string StylesheetProperty = "5555da4f-a123-42b2-4488-dcdfb25e4111";
///
diff --git a/src/Umbraco.Core/Persistence/DatabaseFactory.cs b/src/Umbraco.Core/Persistence/DatabaseFactory.cs
deleted file mode 100644
index 6ce5bd6ac4..0000000000
--- a/src/Umbraco.Core/Persistence/DatabaseFactory.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Threading;
-using Umbraco.Core.Configuration;
-
-namespace Umbraco.Core.Persistence
-{
- ///
- /// Provides access to the PetaPoco database as Singleton, so the database is created once in app lifecycle.
- /// This is necessary for transactions to work properly
- ///
- public sealed class DatabaseFactory
- {
- #region Singleton
-
- private static readonly Database _database = new Database(GlobalSettings.DbDsn);
- private static readonly Lazy lazy = new Lazy(() => new DatabaseFactory());
-
- public static DatabaseFactory Current { get { return lazy.Value; } }
-
- private DatabaseFactory()
- {
- }
-
- #endregion
-
- ///
- /// Returns an instance of the PetaPoco database
- ///
- public Database Database
- {
- get { return _database; }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs
index e173bccc6d..07fc3db387 100644
--- a/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/MigrationContext.cs
@@ -1,15 +1,17 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using Umbraco.Core.Logging;
namespace Umbraco.Core.Persistence.Migrations
{
internal class MigrationContext : IMigrationContext
{
- public MigrationContext(DatabaseProviders databaseProvider, Database database)
+ public MigrationContext(DatabaseProviders databaseProvider, Database database, ILogger logger)
{
Expressions = new Collection();
CurrentDatabaseProvider = databaseProvider;
Database = database;
+ Logger = logger;
}
public ICollection Expressions { get; set; }
@@ -17,5 +19,7 @@ namespace Umbraco.Core.Persistence.Migrations
public DatabaseProviders CurrentDatabaseProvider { get; private set; }
public Database Database { get; private set; }
+
+ public ILogger Logger { get; private set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateAndRemoveTemplateMasterColumn.cs
similarity index 98%
rename from src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs
rename to src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateAndRemoveTemplateMasterColumn.cs
index 43dbbb3e53..32ce0df07c 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateAndRemoveTemplateMasterColumn.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZe
///
/// Remove the master column after we've migrated all of the values into the 'ParentId' and Path column of Umbraco node
///
- [Migration("7.3.0", 0, GlobalSettings.UmbracoMigrationName)]
+ [Migration("7.3.0", 1, GlobalSettings.UmbracoMigrationName)]
public class MigrateAndRemoveTemplateMasterColumn : MigrationBase
{
public override void Up()
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateStylesheetDataToFile.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateStylesheetDataToFile.cs
new file mode 100644
index 0000000000..1b169d8e68
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateStylesheetDataToFile.cs
@@ -0,0 +1,132 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.IO;
+using Umbraco.Core.Models;
+using File = System.IO.File;
+
+namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
+{
+ ///
+ /// Ensures that any stylesheets that have properties defined at the db level have the correct new syntax
+ /// in their files before we remove the stylesheet db tables
+ ///
+ ///
+ /// Instead of modifying the files directly (since we cannot roll them back) we will create temporary migrated files.
+ /// These files will then be copied over once the entire migration is complete so that if any migration fails and the db changes are
+ /// rolled back, the original files won't be affected.
+ ///
+ [Migration("7.3.0", 2, GlobalSettings.UmbracoMigrationName)]
+ public class MigrateStylesheetDataToFile : MigrationBase
+ {
+ public override void Up()
+ {
+ //This is all rather nasty but it's how stylesheets used to work in the 2 various ugly ways so we just have to
+ // deal with that to get this migration done
+
+
+ var tempFolder = IOHelper.MapPath("~/App_Data/TEMP/CssMigration/");
+ if (Directory.Exists(tempFolder))
+ {
+ //clear any existing css files (we back the real ones up so if this migration is run again for whatever reason anything that
+ // was previously backed up is still there, backup happens in a post migration: OverwriteStylesheetFilesFromTempFiles class)
+ var files = Directory.GetFiles(tempFolder, "*.css", SearchOption.AllDirectories);
+ foreach (var file in files)
+ {
+ File.Delete(file);
+ }
+ }
+ //create the temp folder
+ var tempDir = Directory.CreateDirectory(IOHelper.MapPath("~/App_Data/TEMP/CssMigration/"));
+
+
+ var sheets = Context.Database.Fetch("SELECT * FROM cmsStylesheet INNER JOIN umbracoNode on cmsStylesheet.nodeId = umbracoNode.id");
+ foreach (var sheet in sheets)
+ {
+ var fileName = sheet.text;
+
+ string dbContent;
+ //we will always use the file content over the db content if there is any
+ using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(sheet.content)))
+ {
+ dbContent = GetContentAboveUmbracoProps(memStream);
+ }
+
+ var fileContent = string.Empty;
+
+ //check for file and read in it's data - umbraco properties will only be kept that are in the db,
+ // anything below the infamous: /* EDITOR PROPERTIES - PLEASE DON'T DELETE THIS LINE TO AVOID DUPLICATE PROPERTIES */
+ // line is an Umbraco property and therefore anything that is there that is not in the db will be cleared.
+
+ var filePath = IOHelper.MapPath(string.Format("{0}/{1}.css", SystemDirectories.Css, fileName));
+ if (File.Exists(filePath))
+ {
+ using (var stream = File.OpenRead(filePath))
+ {
+ fileContent = GetContentAboveUmbracoProps(stream);
+ }
+ }
+
+ var props = Context.Database.Fetch("SELECT * FROM cmsStylesheetProperty INNER JOIN umbracoNode ON cmsStylesheetProperty.nodeId = umbracoNode.id WHere umbracoNode.parentID = @id", new { id = sheet.nodeId });
+
+ var cssFolderPath = IOHelper.MapPath(SystemDirectories.Css);
+ var relativeFsPath = StringExtensions.TrimStart(StringExtensions.TrimStart(filePath, cssFolderPath), "\\");
+ var stylesheetInstance = new Stylesheet(relativeFsPath)
+ {
+ Content = fileContent.IsNullOrWhiteSpace() ? dbContent : fileContent
+ };
+
+ foreach (var prop in props)
+ {
+ if (stylesheetInstance.Properties.Any(x => x.Name == prop.text) == false)
+ {
+ stylesheetInstance.AddProperty(new StylesheetProperty(prop.text, prop.stylesheetPropertyAlias, prop.stylesheetPropertyValue));
+ }
+ }
+
+ //Save to temp folder
+
+ //ensure the folder for the file exists since it could be in a sub folder
+ var tempFilePath = Path.Combine(tempDir.FullName, relativeFsPath);
+ Directory.CreateDirectory(Path.GetDirectoryName(tempFilePath));
+
+ File.WriteAllText(tempFilePath, stylesheetInstance.Content, Encoding.UTF8);
+
+ }
+ }
+
+ public override void Down()
+ {
+ throw new NotSupportedException("Cannot downgrade from 7.3 as there are database table deletions");
+ }
+
+ private string GetContentAboveUmbracoProps(Stream stream)
+ {
+ var content = string.Empty;
+ using (var re = new StreamReader(stream))
+ {
+ string input;
+ var readingProperties = false;
+
+ while ((input = re.ReadLine()) != null)
+ {
+ //This is that line that was in there before that was delimiting umb props from normal css:
+ // /* EDITOR PROPERTIES - PLEASE DON'T DELETE THIS LINE TO AVOID DUPLICATE PROPERTIES */
+ if (input.Contains("EDITOR PROPERTIES"))
+ {
+ readingProperties = true;
+ continue;
+ }
+
+ if (readingProperties == false)
+ {
+ content += input;
+ }
+ }
+ }
+ return content;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 9daa868dc7..6731114dc3 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -319,6 +319,7 @@
+
@@ -401,7 +402,7 @@
-
+
diff --git a/src/Umbraco.Web/Strategies/Migrations/ClearCsrfCookiesAfterUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/ClearCsrfCookiesAfterUpgrade.cs
index 8e76053a09..0b31f53c74 100644
--- a/src/Umbraco.Web/Strategies/Migrations/ClearCsrfCookiesAfterUpgrade.cs
+++ b/src/Umbraco.Web/Strategies/Migrations/ClearCsrfCookiesAfterUpgrade.cs
@@ -1,4 +1,5 @@
using System.Web;
+using Umbraco.Core.Events;
using Umbraco.Core.Persistence.Migrations;
using Umbraco.Web.WebApi.Filters;
using umbraco.interfaces;
@@ -8,14 +9,9 @@ namespace Umbraco.Web.Strategies.Migrations
///
/// After upgrade we clear out the csrf tokens
///
- public class ClearCsrfCookiesAfterUpgrade : IApplicationStartupHandler
+ public class ClearCsrfCookiesAfterUpgrade : MigrationStartupHander
{
- public ClearCsrfCookiesAfterUpgrade()
- {
- MigrationRunner.Migrated += MigrationRunner_Migrated;
- }
-
- void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
+ protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
if (HttpContext.Current == null) return;
diff --git a/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs
index 3a498ea92f..54b4144fc0 100644
--- a/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs
+++ b/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs
@@ -1,5 +1,6 @@
using System;
using Umbraco.Core;
+using Umbraco.Core.Events;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.Migrations;
using Umbraco.Core.Persistence.SqlSyntax;
@@ -15,14 +16,9 @@ namespace Umbraco.Web.Strategies.Migrations
///
/// * If current is less than or equal to 7.0.0
///
- public class ClearMediaXmlCacheForDeletedItemsAfterUpgrade : IApplicationStartupHandler
- {
- public ClearMediaXmlCacheForDeletedItemsAfterUpgrade()
- {
- MigrationRunner.Migrated += MigrationRunner_Migrated;
- }
-
- void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
+ public class ClearMediaXmlCacheForDeletedItemsAfterUpgrade : MigrationStartupHander
+ {
+ protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
var target70 = new Version(7, 0, 0);
@@ -34,7 +30,7 @@ namespace Umbraco.Web.Strategies.Migrations
var sql = @"DELETE FROM cmsContentXml WHERE nodeId IN
(SELECT nodeId FROM (SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml
INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id
- WHERE nodeObjectType = '" + Constants.ObjectTypes.Media +"' AND " + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("path") + " LIKE '%-21%') x)";
+ WHERE nodeObjectType = '" + Constants.ObjectTypes.Media + "' AND " + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("path") + " LIKE '%-21%') x)";
var count = e.MigrationContext.Database.Execute(sql);
diff --git a/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs
index 582980b0bc..96373f60fd 100644
--- a/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs
+++ b/src/Umbraco.Web/Strategies/Migrations/EnsureAppsTreesUpdatedOnUpgrade.cs
@@ -1,4 +1,5 @@
-using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
+using Umbraco.Core;
+using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
using umbraco.BusinessLogic;
using umbraco.interfaces;
@@ -8,14 +9,30 @@ namespace Umbraco.Web.Strategies.Migrations
/// This is kind of a hack to ensure that Apps and Trees that might still reside in the db is
/// written to the 'new' applications.config and trees.config files upon upgrade to version 6.0
///
- public class EnsureAppsTreesUpdatedOnUpgrade : IApplicationStartupHandler
+ public class EnsureAppsTreesUpdatedOnUpgrade : ApplicationEventHandler
{
- public EnsureAppsTreesUpdatedOnUpgrade()
+ ///
+ /// Ensure this is run when not configured
+ ///
+ protected override bool ExecuteWhenApplicationNotConfigured
+ {
+ get { return true; }
+ }
+
+ ///
+ /// Ensure this is run when not configured
+ ///
+ protected override bool ExecuteWhenDatabaseNotConfigured
+ {
+ get { return true; }
+ }
+
+ protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
//This event will be triggered once the EnsureAppsTreesUpdated Up() method is run during upgrades
EnsureAppsTreesUpdated.Upgrading += EnsureAppsTreesUpdated_Upgrading;
}
-
+
void EnsureAppsTreesUpdated_Upgrading(object sender, EnsureAppsTreesUpdated.UpgradingEventArgs e)
{
var treeRegistrar = new ApplicationTreeRegistrar();
diff --git a/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs b/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs
index ba0ac7b387..610c57b592 100644
--- a/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs
+++ b/src/Umbraco.Web/Strategies/Migrations/EnsureListViewDataTypeIsCreated.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
+using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
@@ -15,46 +16,20 @@ namespace Umbraco.Web.Strategies.Migrations
///
/// Creates the built in list view data types
///
- public class EnsureDefaultListViewDataTypesCreated : ApplicationEventHandler
+ public class EnsureDefaultListViewDataTypesCreated : MigrationStartupHander
{
- ///
- /// Ensure this is run when not configured
- ///
- protected override bool ExecuteWhenApplicationNotConfigured
- {
- get { return true; }
- }
-
- ///
- /// Ensure this is run when not configured
- ///
- protected override bool ExecuteWhenDatabaseNotConfigured
- {
- get { return true; }
- }
-
- ///
- /// Attach to event on starting
- ///
- ///
- ///
- protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
- {
- MigrationRunner.Migrated += MigrationRunner_Migrated;
- }
-
- void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
+ protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
var target720 = new Version(7, 2, 0);
if (e.ConfiguredVersion <= target720)
{
EnsureListViewDataTypeCreated(e);
-
+
}
}
- private void EnsureListViewDataTypeCreated(Core.Events.MigrationEventArgs e)
+ private void EnsureListViewDataTypeCreated(MigrationEventArgs e)
{
var exists = e.MigrationContext.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoNode WHERE id=1037");
if (exists > 0) return;
diff --git a/src/Umbraco.Web/Strategies/Migrations/MigrationStartupHander.cs b/src/Umbraco.Web/Strategies/Migrations/MigrationStartupHander.cs
new file mode 100644
index 0000000000..6b2c92f79f
--- /dev/null
+++ b/src/Umbraco.Web/Strategies/Migrations/MigrationStartupHander.cs
@@ -0,0 +1,49 @@
+using Umbraco.Core;
+using Umbraco.Core.Persistence.Migrations;
+
+namespace Umbraco.Web.Strategies.Migrations
+{
+ ///
+ /// Base class that can be used to run code after the migration runner has executed
+ ///
+ public abstract class MigrationStartupHander : ApplicationEventHandler
+ {
+ ///
+ /// Ensure this is run when not configured
+ ///
+ protected override bool ExecuteWhenApplicationNotConfigured
+ {
+ get { return true; }
+ }
+
+ ///
+ /// Ensure this is run when not configured
+ ///
+ protected override bool ExecuteWhenDatabaseNotConfigured
+ {
+ get { return true; }
+ }
+
+ public void Unsubscribe()
+ {
+ MigrationRunner.Migrated -= MigrationRunner_Migrated;
+ }
+
+ ///
+ /// Attach to event on starting
+ ///
+ ///
+ ///
+ protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
+ {
+ MigrationRunner.Migrated += MigrationRunner_Migrated;
+ }
+
+ private void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
+ {
+ AfterMigration(sender, e);
+ }
+
+ protected abstract void AfterMigration(MigrationRunner sender, Core.Events.MigrationEventArgs e);
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Strategies/Migrations/OverwriteStylesheetFilesFromTempFiles.cs b/src/Umbraco.Web/Strategies/Migrations/OverwriteStylesheetFilesFromTempFiles.cs
new file mode 100644
index 0000000000..a8ef08cce0
--- /dev/null
+++ b/src/Umbraco.Web/Strategies/Migrations/OverwriteStylesheetFilesFromTempFiles.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Umbraco.Core.Events;
+using Umbraco.Core;
+using Umbraco.Core.IO;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Persistence.Migrations;
+
+namespace Umbraco.Web.Strategies.Migrations
+{
+
+ ///
+ /// When upgrading version 7.3 the migration MigrateStylesheetDataToFile will execute but we don't want to overwrite the developers
+ /// files during the migration since other parts of the migration might fail. So once the migration is complete, we'll then copy over the temp
+ /// files that this migration created over top of the developer's files. We'll also create a backup of their files.
+ ///
+ public sealed class OverwriteStylesheetFilesFromTempFiles : MigrationStartupHander
+ {
+ protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
+ {
+ var target73 = new Version(7, 3, 0);
+
+ if (e.ConfiguredVersion <= target73)
+ {
+ var tempCssFolder = IOHelper.MapPath("~/App_Data/TEMP/CssMigration/");
+ var cssFolder = IOHelper.MapPath("~/css");
+ if (Directory.Exists(tempCssFolder))
+ {
+ var files = Directory.GetFiles(tempCssFolder, "*.css", SearchOption.AllDirectories);
+ foreach (var file in files)
+ {
+ var relativePath = file.TrimStart(tempCssFolder).TrimStart("\\");
+ var cssFilePath = Path.Combine(cssFolder, relativePath);
+ if (File.Exists(cssFilePath))
+ {
+ //backup
+ var targetPath = Path.Combine(tempCssFolder, relativePath.EnsureEndsWith(".bak"));
+ e.MigrationContext.Logger.Info("CSS file is being backed up from {0}, to {1} before being migrated to new format", () => cssFilePath, () => targetPath);
+ File.Copy(cssFilePath, targetPath, true);
+ }
+
+ //ensure the sub folder eixts
+ Directory.CreateDirectory(Path.GetDirectoryName(cssFilePath));
+ File.Copy(file, cssFilePath, true);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Web/Strategies/Migrations/PublishAfterUpgradeToVersionSixth.cs b/src/Umbraco.Web/Strategies/Migrations/PublishAfterUpgradeToVersionSixth.cs
index 43c0157c7e..3e0df97e88 100644
--- a/src/Umbraco.Web/Strategies/Migrations/PublishAfterUpgradeToVersionSixth.cs
+++ b/src/Umbraco.Web/Strategies/Migrations/PublishAfterUpgradeToVersionSixth.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Umbraco.Core.Events;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Migrations;
@@ -14,19 +15,9 @@ namespace Umbraco.Web.Strategies.Migrations
/// This event ensures that upgrades from (configured) versions lower then 6.0.0
/// have their publish state updated after the database schema has been migrated.
///
- public class PublishAfterUpgradeToVersionSixth : IApplicationStartupHandler
+ public class PublishAfterUpgradeToVersionSixth : MigrationStartupHander
{
- public PublishAfterUpgradeToVersionSixth()
- {
- MigrationRunner.Migrated += MigrationRunner_Migrated;
- }
-
- public void Unsubscribe()
- {
- MigrationRunner.Migrated -= MigrationRunner_Migrated;
- }
-
- void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
+ protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
var target = new Version(6, 0, 0);
if (e.ConfiguredVersion < target)
@@ -43,8 +34,6 @@ namespace Umbraco.Web.Strategies.Migrations
.Where(x => x.NodeObjectType == new Guid(Constants.ObjectTypes.Document))
.Where(x => x.Path.StartsWith("-1"));
-
-
var dtos = e.MigrationContext.Database.Fetch(sql);
var toUpdate = new List();
var versionGroup = dtos.GroupBy(x => x.NodeId);
@@ -80,6 +69,7 @@ namespace Umbraco.Web.Strategies.Migrations
transaction.Complete();
}
}
- }
+ }
+
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs
index 72cf6c24ea..fad63c66dc 100644
--- a/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs
+++ b/src/Umbraco.Web/Strategies/Migrations/RebuildMediaXmlCacheAfterUpgrade.cs
@@ -1,5 +1,6 @@
using System;
using Umbraco.Core;
+using Umbraco.Core.Events;
using Umbraco.Core.Persistence.Migrations;
using Umbraco.Core.Services;
using umbraco.interfaces;
@@ -16,14 +17,9 @@ namespace Umbraco.Web.Strategies.Migrations
///
/// * If current is less than or equal to 7.0.0
///
- public class RebuildMediaXmlCacheAfterUpgrade : IApplicationStartupHandler
+ public class RebuildMediaXmlCacheAfterUpgrade : MigrationStartupHander
{
- public RebuildMediaXmlCacheAfterUpgrade()
- {
- MigrationRunner.Migrated += MigrationRunner_Migrated;
- }
-
- void MigrationRunner_Migrated(MigrationRunner sender, Core.Events.MigrationEventArgs e)
+ protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
{
var target70 = new Version(7, 0, 0);
@@ -32,7 +28,6 @@ namespace Umbraco.Web.Strategies.Migrations
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 50b0bd0c55..ac7ee60e4c 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -501,6 +501,8 @@
+
+
diff --git a/src/umbraco.cms/businesslogic/web/StyleSheet.cs b/src/umbraco.cms/businesslogic/web/StyleSheet.cs
index 1444307d85..cc53877a26 100644
--- a/src/umbraco.cms/businesslogic/web/StyleSheet.cs
+++ b/src/umbraco.cms/businesslogic/web/StyleSheet.cs
@@ -110,12 +110,7 @@ namespace umbraco.cms.businesslogic.web
public override string Text
{
get { return Filename; }
- set
- {
- var currFileName = System.IO.Path.GetFileName(StylesheetItem.Path);
- var newFilePath = StylesheetItem.Path.TrimEnd(currFileName) + value;
- StylesheetItem.Path = newFilePath;
- }
+ set { Filename = value; }
}
///