diff --git a/src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/Expressions/InsertDataExpression.cs b/src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/Expressions/InsertDataExpression.cs index dcc58c60bc..b9f076ac7f 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/Expressions/InsertDataExpression.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/Expressions/InsertDataExpression.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.SqlSyntax; @@ -43,7 +44,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Insert.Expressions foreach (var keyVal in item) { cols += keyVal.Key + ","; - vals += keyVal.Value + ","; + vals += GetQuotedValue(keyVal.Value) + ","; } cols = cols.TrimEnd(','); vals = vals.TrimEnd(','); @@ -58,5 +59,29 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Insert.Expressions return string.Join(",", insertItems); } + + private string GetQuotedValue(object val) + { + var type = val.GetType(); + switch (Type.GetTypeCode(type)) + { + case TypeCode.Boolean: + return ((bool) val) ? "1" : "0"; + case TypeCode.Single: + case TypeCode.Double: + case TypeCode.Decimal: + case TypeCode.SByte: + case TypeCode.Int16: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.Byte: + case TypeCode.UInt16: + case TypeCode.UInt32: + case TypeCode.UInt64: + return val.ToString(); + default: + return SqlSyntaxContext.SqlSyntaxProvider.GetQuotedValue(val.ToString()); + } + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddRelationTypeForDocumentOnDelete.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddRelationTypeForDocumentOnDelete.cs index e46085897b..c656376a9f 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddRelationTypeForDocumentOnDelete.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddRelationTypeForDocumentOnDelete.cs @@ -9,14 +9,15 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZe { public override void Up() { - Execute.Code(AddRelationType); - } + Insert.IntoTable("umbracoRelationType").Row(new + { + dual = false, + parentObjectType = Guid.Parse(Constants.ObjectTypes.Document), + childObjectType = Guid.Parse(Constants.ObjectTypes.Document), + name = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName, + alias = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias + }); - public static string AddRelationType(Database database) - { - database.Insert("umbracoRelationType", "id", false, new RelationTypeDto { Alias = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteAlias, ChildObjectType = new Guid(Constants.ObjectTypes.Document), ParentObjectType = new Guid(Constants.ObjectTypes.Document), Dual = false, Name = Constants.Conventions.RelationTypes.RelateParentDocumentOnDeleteName }); - - return string.Empty; } public override void Down() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs index aa6cb715be..43dbbb3e53 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/RemoveTemplateMasterColumn.cs @@ -15,6 +15,13 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZe public override void Up() { + //Don't execute anything if there is no 'master' column - this might occur if the db is already upgraded + var cols = SqlSyntaxContext.SqlSyntaxProvider.GetColumnsInSchema(Context.Database); + if (cols.Any(x => x.ColumnName.InvariantEquals("master") && x.TableName.InvariantEquals("cmsTemplate")) == false) + { + return; + } + //update the parentId column for all templates to be correct so it matches the current 'master' template //NOTE: we are using dynamic because we need to get the data in a column that no longer exists in the schema var templates = Context.Database.Fetch(new Sql().Select("*").From()); diff --git a/src/Umbraco.Web/Strategies/RelateOnTrashHandler.cs b/src/Umbraco.Core/Strategies/RelateOnTrashHandler.cs similarity index 93% rename from src/Umbraco.Web/Strategies/RelateOnTrashHandler.cs rename to src/Umbraco.Core/Strategies/RelateOnTrashHandler.cs index 8b3cd598a2..ffe55eadcc 100644 --- a/src/Umbraco.Web/Strategies/RelateOnTrashHandler.cs +++ b/src/Umbraco.Core/Strategies/RelateOnTrashHandler.cs @@ -1,16 +1,15 @@ using System; using System.Linq; -using Umbraco.Core; using Umbraco.Core.Auditing; using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Services; -namespace Umbraco.Web.Strategies +namespace Umbraco.Core.Strategies { public sealed class RelateOnTrashHandler : ApplicationEventHandler { - protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { ContentService.Moved += ContentService_Moved; ContentService.Trashed += ContentService_Trashed; diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 4f7ae5b574..5b3a6c6ced 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -1097,6 +1097,8 @@ + + diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 4152e75e10..43e05789b8 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -496,7 +496,6 @@ - diff --git a/src/umbraco.cms/Actions/ActionRestore.cs b/src/umbraco.cms/Actions/ActionRestore.cs index 21079861ae..9b38918fd4 100644 --- a/src/umbraco.cms/Actions/ActionRestore.cs +++ b/src/umbraco.cms/Actions/ActionRestore.cs @@ -4,92 +4,84 @@ using umbraco.BasePages; namespace umbraco.BusinessLogic.Actions { - /// - /// This action is invoked when the content item is to be restored from the recycle bin - /// - public class ActionRestore : IAction - { - //create singleton -#pragma warning disable 612,618 - private static readonly ActionRestore m_instance = new ActionRestore(); -#pragma warning restore 612,618 + /// + /// This action is invoked when the content item is to be restored from the recycle bin + /// + public class ActionRestore : IAction + { + //create singleton + private static readonly ActionRestore SingletonInstance = new ActionRestore(); - /// - /// A public constructor exists ONLY for backwards compatibility in regards to 3rd party add-ons. - /// All Umbraco assemblies should use the singleton instantiation (this.Instance) - /// When this applicatio is refactored, this constuctor should be made private. - /// - [Obsolete("Use the singleton instantiation instead of a constructor")] - public ActionRestore() { } + private ActionRestore() { } - public static ActionRestore Instance - { - get { return m_instance; } - } + public static ActionRestore Instance + { + get { return SingletonInstance; } + } - #region IAction Members + #region IAction Members - public char Letter - { - get - { - return 'V'; - } - } + public char Letter + { + get + { + return 'V'; + } + } - public string JsFunctionName - { - get - { - return null; - } - } + public string JsFunctionName + { + get + { + return null; + } + } - public string JsSource - { - get - { + public string JsSource + { + get + { - return null; - } - } + return null; + } + } - public string Alias - { - get - { + public string Alias + { + get + { - return "restore"; - } - } + return "restore"; + } + } - public string Icon - { - get - { + public string Icon + { + get + { - return "undo"; - } - } + return "undo"; + } + } - public bool ShowInNotifier - { - get - { + public bool ShowInNotifier + { + get + { - return true; - } - } + return true; + } + } - public bool CanBePermissionAssigned - { - get - { + public bool CanBePermissionAssigned + { + get + { - return true; - } - } + return false; + } + } - #endregion - } + #endregion + } } \ No newline at end of file