From 349d89e4d7783ae90a53a0302d1c1beb231f330c Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 22 Sep 2017 13:08:05 +0200 Subject: [PATCH 1/5] deploy-401 - fix id reservations --- src/Umbraco.Core/Services/IdkMap.cs | 12 ++--- .../Services/EntityServiceTests.cs | 52 ++++++++++++++----- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Core/Services/IdkMap.cs b/src/Umbraco.Core/Services/IdkMap.cs index 411316fca2..bd3acd5527 100644 --- a/src/Umbraco.Core/Services/IdkMap.cs +++ b/src/Umbraco.Core/Services/IdkMap.cs @@ -10,7 +10,7 @@ namespace Umbraco.Core.Services { private readonly IDatabaseUnitOfWorkProvider _uowProvider; private readonly ReaderWriterLockSlim _locker = new ReaderWriterLockSlim(); - + private readonly Dictionary> _id2Key = new Dictionary>(); private readonly Dictionary> _key2Id = new Dictionary>(); @@ -39,8 +39,8 @@ namespace Umbraco.Core.Services int? val; using (var uow = _uowProvider.GetUnitOfWork()) { - val = uow.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id AND nodeObjectType=@nodeObjectType", - new { id = key, nodeObjectType = GetNodeObjectTypeGuid(umbracoObjectType) }); + val = uow.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)", + new { id = key, type = GetNodeObjectTypeGuid(umbracoObjectType), reservation = Constants.ObjectTypes.IdReservationGuid }); uow.Commit(); } @@ -92,8 +92,8 @@ namespace Umbraco.Core.Services Guid? val; using (var uow = _uowProvider.GetUnitOfWork()) { - val = uow.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id AND nodeObjectType=@nodeObjectType", - new { id, nodeObjectType = GetNodeObjectTypeGuid(umbracoObjectType) }); + val = uow.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)", + new { id, type = GetNodeObjectTypeGuid(umbracoObjectType), reservation = Constants.ObjectTypes.IdReservationGuid }); uow.Commit(); } @@ -179,7 +179,7 @@ namespace Umbraco.Core.Services { private readonly T _id; private readonly UmbracoObjectTypes _umbracoObjectType; - + public T Id { get { return _id; } diff --git a/src/Umbraco.Tests/Services/EntityServiceTests.cs b/src/Umbraco.Tests/Services/EntityServiceTests.cs index 021c0d6c36..0dee46e07e 100644 --- a/src/Umbraco.Tests/Services/EntityServiceTests.cs +++ b/src/Umbraco.Tests/Services/EntityServiceTests.cs @@ -26,15 +26,15 @@ namespace Umbraco.Tests.Services public override void TearDown() { base.TearDown(); - } + } [Test] public void EntityService_Can_Get_Paged_Content_Children() { - + var contentType = ServiceContext.ContentTypeService.GetContentType("umbTextpage"); - - var root = MockedContent.CreateSimpleContent(contentType); + + var root = MockedContent.CreateSimpleContent(contentType); ServiceContext.ContentService.Save(root); for (int i = 0; i < 10; i++) { @@ -45,7 +45,7 @@ namespace Umbraco.Tests.Services var service = ServiceContext.EntityService; long total; - var entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Document, 0, 6, out total).ToArray(); + var entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Document, 0, 6, out total).ToArray(); Assert.That(entities.Length, Is.EqualTo(6)); Assert.That(total, Is.EqualTo(10)); entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Document, 1, 6, out total).ToArray(); @@ -72,7 +72,7 @@ namespace Umbraco.Tests.Services var c2 = MockedContent.CreateSimpleContent(contentType, Guid.NewGuid().ToString(), c1); ServiceContext.ContentService.Save(c2); count++; - } + } } var service = ServiceContext.EntityService; @@ -181,7 +181,7 @@ namespace Umbraco.Tests.Services var root = MockedContent.CreateSimpleContent(contentType); ServiceContext.ContentService.Save(root); - + for (int i = 0; i < 10; i++) { var c1 = MockedContent.CreateSimpleContent(contentType, "ssss" + Guid.NewGuid(), root); @@ -204,7 +204,7 @@ namespace Umbraco.Tests.Services Assert.That(entities.Length, Is.EqualTo(50)); Assert.That(total, Is.EqualTo(50)); } - + [Test] public void EntityService_Can_Get_Paged_Media_Children() { @@ -227,7 +227,7 @@ namespace Umbraco.Tests.Services Assert.That(total, Is.EqualTo(10)); entities = service.GetPagedChildren(root.Id, UmbracoObjectTypes.Media, 1, 6, out total).ToArray(); Assert.That(entities.Length, Is.EqualTo(4)); - Assert.That(total, Is.EqualTo(10)); + Assert.That(total, Is.EqualTo(10)); } [Test] @@ -362,7 +362,7 @@ namespace Umbraco.Tests.Services var root = MockedMedia.CreateMediaFolder(folderType, -1); ServiceContext.MediaService.Save(root); - + for (int i = 0; i < 10; i++) { var c1 = MockedMedia.CreateMediaImage(imageMediaType, root.Id); @@ -519,7 +519,7 @@ namespace Umbraco.Tests.Services Assert.That( entities.Any( x => - x.AdditionalData.Any(y => y.Value is UmbracoEntity.EntityProperty + x.AdditionalData.Any(y => y.Value is UmbracoEntity.EntityProperty && ((UmbracoEntity.EntityProperty)y.Value).PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias)), Is.True); } @@ -575,6 +575,30 @@ namespace Umbraco.Tests.Services Assert.IsFalse(result2.Success); } + [Test] + public void ReserveId() + { + var service = ServiceContext.EntityService; + var guid = Guid.NewGuid(); + + // can reserve + var reservedId = service.ReserveId(guid); + Assert.IsTrue(reservedId > 0); + + // can get it back + var id = service.GetIdForKey(guid, UmbracoObjectTypes.DocumentType); + Assert.IsTrue(id.Success); + Assert.AreEqual(reservedId, id.Result); + + // anything goes + id = service.GetIdForKey(guid, UmbracoObjectTypes.Media); + Assert.IsTrue(id.Success); + Assert.AreEqual(reservedId, id.Result); + + // a random guid won't work + Assert.IsFalse(service.GetIdForKey(Guid.NewGuid(), UmbracoObjectTypes.DocumentType).Success); + } + private static bool _isSetup = false; private int folderId; @@ -589,7 +613,7 @@ namespace Umbraco.Tests.Services //Create and Save folder-Media -> 1050 var folderMediaType = ServiceContext.ContentTypeService.GetMediaType(1031); - var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1); + var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1); ServiceContext.MediaService.Save(folder, 0); folderId = folder.Id; @@ -607,9 +631,9 @@ namespace Umbraco.Tests.Services ServiceContext.MediaService.Save(subfolder, 0); var subfolder2 = MockedMedia.CreateMediaFolder(folderMediaType, subfolder.Id); ServiceContext.MediaService.Save(subfolder2, 0); - + } - + } } } \ No newline at end of file From 963015cf4aac1e80d6fd9ed6204a06f7a1398a1a Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 20 Sep 2017 19:03:00 +0200 Subject: [PATCH 2/5] Fix LocalDb detection on 32/64 bits systems (cherry picked from commit a239e92bc0bc27cf91b0f3fd30f259f0a011e2db) --- src/Umbraco.Core/Persistence/LocalDb.cs | 31 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/Persistence/LocalDb.cs b/src/Umbraco.Core/Persistence/LocalDb.cs index f706979e17..4dcc56a9a4 100644 --- a/src/Umbraco.Core/Persistence/LocalDb.cs +++ b/src/Umbraco.Core/Persistence/LocalDb.cs @@ -24,6 +24,7 @@ namespace Umbraco.Core.Persistence { private int _version; private bool _hasVersion; + private string _exe; #region Availability & Version @@ -84,16 +85,31 @@ namespace Umbraco.Core.Persistence { _hasVersion = true; _version = -1; + _exe = null; var programFiles = Environment.GetEnvironmentVariable("ProgramFiles"); - if (programFiles == null) return; + + // MS SQL Server installs in e.g. "C:\Program Files\Microsoft SQL Server", so + // we want to detect it in "%ProgramFiles%\Microsoft SQL Server" - however, if + // Umbraco runs as a 32bits process (e.g. IISExpress configured as 32bits) + // on a 64bits system, %ProgramFiles% will point to "C:\Program Files (x86)" + // and SQL Server cannot be found. But then, %ProgramW6432% will point to + // the original "C:\Program Files". Using it to fix the path. + // see also: MSDN doc for WOW64 implementation + // + var programW6432 = Environment.GetEnvironmentVariable("ProgramW6432"); + if (string.IsNullOrWhiteSpace(programW6432) == false && programW6432 != programFiles) + programFiles = programW6432; + + if (string.IsNullOrWhiteSpace(programFiles)) return; // detect 14, 13, 12, 11 for (var i = 14; i > 10; i--) { - var path = Path.Combine(programFiles, string.Format(@"Microsoft SQL Server\{0}0\Tools\Binn\SqlLocalDB.exe", i)); - if (File.Exists(path) == false) continue; + var exe = Path.Combine(programFiles, string.Format(@"Microsoft SQL Server\{0}0\Tools\Binn\SqlLocalDB.exe", i)); + if (File.Exists(exe) == false) continue; _version = i; + _exe = exe; break; } } @@ -897,16 +913,13 @@ namespace Umbraco.Core.Persistence /// private int ExecuteSqlLocalDb(string args, out string output, out string error) { - var programFiles = Environment.GetEnvironmentVariable("ProgramFiles"); - if (programFiles == null) + if (_exe == null) // should never happen - we should not execute if not available { output = string.Empty; error = "SqlLocalDB.exe not found"; return -1; } - var path = Path.Combine(programFiles, string.Format(@"Microsoft SQL Server\{0}0\Tools\Binn\SqlLocalDB.exe", _version)); - var p = new Process { StartInfo = @@ -914,7 +927,7 @@ namespace Umbraco.Core.Persistence UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, - FileName = path, + FileName = _exe, Arguments = args, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden @@ -929,7 +942,7 @@ namespace Umbraco.Core.Persistence } /// - /// Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier. + /// Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier. /// /// The name to quote. /// A quote character. From 3ce6eb09aa703ebdf55d923314ef0b6b4757ecaf Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 25 Sep 2017 14:49:59 +1000 Subject: [PATCH 3/5] Ensures HealthCheckController is authorized to user with developer access (cherry picked from commit 7c4eb71f070c87ed7cb493e33556513d2518504c) --- src/Umbraco.Web/HealthCheck/HealthCheckController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Umbraco.Web/HealthCheck/HealthCheckController.cs b/src/Umbraco.Web/HealthCheck/HealthCheckController.cs index 14bfaaea9f..6ce895ba22 100644 --- a/src/Umbraco.Web/HealthCheck/HealthCheckController.cs +++ b/src/Umbraco.Web/HealthCheck/HealthCheckController.cs @@ -3,12 +3,14 @@ using System.Collections.Generic; using System.Linq; using System.Web.Http; using Umbraco.Web.Editors; +using Umbraco.Web.WebApi.Filters; namespace Umbraco.Web.HealthCheck { /// /// The API controller used to display the health check info and execute any actions /// + [UmbracoApplicationAuthorize(Core.Constants.Applications.Developer)] public class HealthCheckController : UmbracoAuthorizedJsonController { private readonly IHealthCheckResolver _healthCheckResolver; From 33cf983cae491dd4414d1553632517b01e65a1cf Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 25 Sep 2017 11:19:36 +0200 Subject: [PATCH 4/5] Bump version --- src/SolutionInfo.cs | 4 ++-- src/Umbraco.Core/Configuration/UmbracoVersion.cs | 2 +- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index d8d55dc8ee..a333fa499d 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -11,5 +11,5 @@ using System.Resources; [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("7.6.8")] -[assembly: AssemblyInformationalVersion("7.6.8")] \ No newline at end of file +[assembly: AssemblyFileVersion("7.6.9")] +[assembly: AssemblyInformationalVersion("7.6.9")] \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs index 612afa7310..1c1724ae84 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration { public class UmbracoVersion { - private static readonly Version Version = new Version("7.6.8"); + private static readonly Version Version = new Version("7.6.9"); /// /// Gets the current version of Umbraco. diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index b70010c7aa..15d48f8f1e 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -2379,9 +2379,9 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.1\x86\*.* "$(TargetDir)x86\" True True - 7680 + 7690 / - http://localhost:7680 + http://localhost:7690 False False From 581eac5369a6eaf6173f1b0a48fbd7ab5e822688 Mon Sep 17 00:00:00 2001 From: Claus Date: Wed, 27 Sep 2017 10:04:07 +0200 Subject: [PATCH 5/5] U4-10470 Missing transform for the scripts tree when upgrading --- build/NuSpecs/tools/trees.config.install.xdt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/NuSpecs/tools/trees.config.install.xdt b/build/NuSpecs/tools/trees.config.install.xdt index 7d41835fb1..db065bbfc3 100644 --- a/build/NuSpecs/tools/trees.config.install.xdt +++ b/build/NuSpecs/tools/trees.config.install.xdt @@ -43,7 +43,7 @@ xdt:Locator="Match(application,alias)" xdt:Transform="InsertIfMissing" /> -