diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddServerRegistrationColumnsAndLock.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddServerRegistrationColumnsAndLock.cs deleted file mode 100644 index 0a29fbb6ef..0000000000 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddServerRegistrationColumnsAndLock.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Linq; -using Umbraco.Core.Configuration; -using Umbraco.Core.Logging; -using Umbraco.Core.Models.Rdbms; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero -{ - [Migration("7.3.0", 17, GlobalSettings.UmbracoMigrationName)] - public class AddServerRegistrationColumnsAndLock : MigrationBase - { - public AddServerRegistrationColumnsAndLock(ISqlSyntaxProvider sqlSyntax, ILogger logger) - : base(sqlSyntax, logger) - { } - - public override void Up() - { - // don't execute if the column is already there - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - if (columns.Any(x => x.TableName.InvariantEquals("umbracoServer") && x.ColumnName.InvariantEquals("isMaster")) == false) - { - Create.Column("isMaster").OnTable("umbracoServer").AsBoolean().NotNullable().WithDefaultValue(0); - } - - // wrap in a transaction so that everything runs on the same connection - // and the IDENTITY_INSERT stuff is effective for all inserts. - using (var tr = Context.Database.GetTransaction()) - { - // turn on identity insert if db provider is not mysql - if (SqlSyntax.SupportsIdentityInsert()) - Context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON", SqlSyntax.GetQuotedTableName("umbracoNode")))); - - InsertLockObject(Constants.System.ServersLock, "0AF5E610-A310-4B6F-925F-E928D5416AF7", "LOCK: Servers"); - - // turn off identity insert if db provider is not mysql - if (SqlSyntax.SupportsIdentityInsert()) - Context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF", SqlSyntax.GetQuotedTableName("umbracoNode")))); - - tr.Complete(); - } - } - - public override void Down() - { - // not implemented - } - - private void InsertLockObject(int id, string uniqueId, string text) - { - var exists = Context.Database.Exists(id); - if (exists) return; - - Context.Database.Insert("umbracoNode", "id", false, new NodeDto - { - NodeId = id, - Trashed = false, - ParentId = -1, - UserId = 0, - Level = 1, - Path = "-1," + id, - SortOrder = 0, - UniqueId = new Guid(uniqueId), - Text = text, - NodeObjectType = new Guid(Constants.ObjectTypes.LockObject), - CreateDate = DateTime.Now - }); - } - } -} diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddServerRegistrationIsMasterColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddServerRegistrationIsMasterColumn.cs new file mode 100644 index 0000000000..b511d8271e --- /dev/null +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/AddServerRegistrationIsMasterColumn.cs @@ -0,0 +1,30 @@ +using System.Linq; +using Umbraco.Core.Configuration; +using Umbraco.Core.Logging; +using Umbraco.Core.Persistence.SqlSyntax; + +namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero +{ + [Migration("7.3.0", 17, GlobalSettings.UmbracoMigrationName)] + public class AddServerRegistrationIsMasterColumn : MigrationBase + { + public AddServerRegistrationIsMasterColumn(ISqlSyntaxProvider sqlSyntax, ILogger logger) + : base(sqlSyntax, logger) + { } + + public override void Up() + { + // don't execute if the column is already there + var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); + if (columns.Any(x => x.TableName.InvariantEquals("umbracoServer") && x.ColumnName.InvariantEquals("isMaster")) == false) + { + Create.Column("isMaster").OnTable("umbracoServer").AsBoolean().NotNullable().WithDefaultValue(0); + } + } + + public override void Down() + { + // not implemented + } + } +} diff --git a/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs b/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs index 16161f4b3a..d0a4c53db7 100644 --- a/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs +++ b/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs @@ -3,6 +3,7 @@ using System.Web; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; +using Umbraco.Core.ObjectResolution; namespace Umbraco.Core.Sync { @@ -14,14 +15,32 @@ namespace Umbraco.Core.Sync // because we cannot logger.Info because type is static private static readonly Type TypeOfApplicationUrlHelper = typeof(ApplicationUrlHelper); + private static Func _applicationUrlProvider; + /// /// Gets or sets a custom provider for the umbraco application url. /// - /// Receives the current request as a parameter, and it may be null. Must return a properly + /// + /// Receives the current request as a parameter, and it may be null. Must return a properly /// formatted url with scheme and umbraco dir and no trailing slash eg "http://www.mysite.com/umbraco", /// or null. To be used in auto-load-balancing scenarios where the application url is not - /// in config files but is determined programmatically. - public static Func ApplicationUrlProvider { get; set; } + /// in config files but is determined programmatically. + /// Must be assigned before resolution is frozen. + /// + public static Func ApplicationUrlProvider + { + get + { + return _applicationUrlProvider; + } + set + { + using (Resolution.Configuration) + { + _applicationUrlProvider = value; + } + } + } // request: will be null if called from ApplicationContext // settings: for unit tests only @@ -37,9 +56,9 @@ namespace Umbraco.Core.Sync return; // try custom provider - if (ApplicationUrlProvider != null) + if (_applicationUrlProvider != null) { - var url = ApplicationUrlProvider(request); + var url = _applicationUrlProvider(request); if (url.IsNullOrWhiteSpace() == false) { appContext._umbracoApplicationUrl = url.TrimEnd('/'); diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index ddc278d026..f3e6cac1f1 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -401,7 +401,7 @@ - + diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js index c1dde8ce23..0569c9faca 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js @@ -308,11 +308,9 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific serial(selected, fn, getStatusMsg, 0).then(function (result) { // executes once the whole selection has been processed - // in case of an error, result will be the error + // in case of an error (caught by serial), result will be the error if (!(result.data && angular.isArray(result.data.notifications))) showNotificationsAndReset(result, true, getSuccessMsg(selected.length)); - }, function (err) { - // never executes, err is caught by serial() }); }; diff --git a/src/Umbraco.Web/Strategies/Migrations/EnsureServerLockNodeExists.cs b/src/Umbraco.Web/Strategies/Migrations/EnsureServerLockNodeExists.cs new file mode 100644 index 0000000000..0659c62383 --- /dev/null +++ b/src/Umbraco.Web/Strategies/Migrations/EnsureServerLockNodeExists.cs @@ -0,0 +1,63 @@ +using System; +using Semver; +using Umbraco.Core; +using Umbraco.Core.Events; +using Umbraco.Core.Models.Rdbms; +using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Migrations; +using Umbraco.Core.Persistence.SqlSyntax; + +namespace Umbraco.Web.Strategies.Migrations +{ + public class EnsureServerLockNodeExists : MigrationStartupHander + { + protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e) + { + var target = new SemVersion(7, 3); + + if (e.ConfiguredSemVersion > target) + return; + + var context = e.MigrationContext; + var sqlSyntax = SqlSyntaxContext.SqlSyntaxProvider; + + // wrap in a transaction so that everything runs on the same connection + // and the IDENTITY_INSERT stuff is effective for all inserts. + using (var tr = context.Database.GetTransaction()) + { + // turn on identity insert if db provider is not mysql + if (sqlSyntax.SupportsIdentityInsert()) + context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON", sqlSyntax.GetQuotedTableName("umbracoNode")))); + + EnsureLockNode(context, Constants.System.ServersLock, "0AF5E610-A310-4B6F-925F-E928D5416AF7", "LOCK: Servers"); + + // turn off identity insert if db provider is not mysql + if (sqlSyntax.SupportsIdentityInsert()) + context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF", sqlSyntax.GetQuotedTableName("umbracoNode")))); + + tr.Complete(); + } + } + + private static void EnsureLockNode(IMigrationContext context, int id, string uniqueId, string text) + { + var exists = context.Database.Exists(id); + if (exists) return; + + context.Database.Insert("umbracoNode", "id", false, new NodeDto + { + NodeId = id, + Trashed = false, + ParentId = -1, + UserId = 0, + Level = 1, + Path = "-1," + id, + SortOrder = 0, + UniqueId = new Guid(uniqueId), + Text = text, + NodeObjectType = new Guid(Constants.ObjectTypes.LockObject), + CreateDate = DateTime.Now + }); + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 3fbdb375a3..b8ed24d5bb 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -312,6 +312,7 @@ +