diff --git a/src/Umbraco.Cms.Persistence.Sqlite/Services/SqliteSyntaxProvider.cs b/src/Umbraco.Cms.Persistence.Sqlite/Services/SqliteSyntaxProvider.cs index fe8bf7b6a1..3803d96490 100644 --- a/src/Umbraco.Cms.Persistence.Sqlite/Services/SqliteSyntaxProvider.cs +++ b/src/Umbraco.Cms.Persistence.Sqlite/Services/SqliteSyntaxProvider.cs @@ -326,7 +326,7 @@ public class SqliteSyntaxProvider : SqlSyntaxProviderBase { IEnumerable tables = GetTablesInSchema(db); - db.OpenSharedConnection(); + db.BeginTransaction(); foreach (var table in tables) { DbCommand? cmd = db.CreateCommand(db.Connection, CommandType.Text, $"PRAGMA table_info({table})"); @@ -341,6 +341,8 @@ public class SqliteSyntaxProvider : SqlSyntaxProviderBase yield return new ColumnInfo(table, columnName, ordinal, notNull, type); } } + + db.CompleteTransaction(); } /// diff --git a/src/Umbraco.Core/Extensions/ObjectExtensions.cs b/src/Umbraco.Core/Extensions/ObjectExtensions.cs index 6dc220446b..f0f10d8cc6 100644 --- a/src/Umbraco.Core/Extensions/ObjectExtensions.cs +++ b/src/Umbraco.Core/Extensions/ObjectExtensions.cs @@ -8,6 +8,7 @@ using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Xml; +using Microsoft.Extensions.Primitives; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Collections; @@ -189,9 +190,10 @@ public static class ObjectExtensions else { // target is not a generic type - if (input is string inputString) + var inputString = input as string ?? (input is StringValues sv ? sv.ToString() : null); + if (inputString != null) { - // Try convert from string, returns an Attempt if the string could be + // Try convert from string or StringValues, returns an Attempt if the string could be // processed (either succeeded or failed), else null if we need to try // other methods Attempt? result = TryConvertToFromString(inputString, target); diff --git a/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs b/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs index 62663e165c..a0330d75fd 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs @@ -133,7 +133,7 @@ public class PackagingService : IPackagingService var currentPlans = installedPackage.PackageMigrationPlans.ToList(); if (keyValues is null || keyValues.TryGetValue( Constants.Conventions.Migrations.KeyValuePrefix + plan.Name, - out var currentState)) + out var currentState) is false) { currentState = null; } diff --git a/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs index 8823b62131..4cdd8cef7c 100644 --- a/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs @@ -136,7 +136,7 @@ public class ContentTreeController : ContentTreeControllerBase, ISearchableTreeW var documentEntity = (IDocumentEntitySlim)entity; - if (!documentEntity.Variations.VariesByCulture()) + if (!documentEntity.Variations.VariesByCulture() || culture.IsNullOrWhiteSpace()) { if (!documentEntity.Published) { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockgrid/prevalue/blockgrid.blockconfiguration.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockgrid/prevalue/blockgrid.blockconfiguration.controller.js index f24520dda6..85c31dfc6b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockgrid/prevalue/blockgrid.blockconfiguration.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockgrid/prevalue/blockgrid.blockconfiguration.controller.js @@ -41,8 +41,9 @@ function BlockConfigurationController($scope, $element, $http, elementTypeResource, overlayService, localizationService, editorService, eventsService, udiService, dataTypeResource, umbRequestHelper) { var unsubscribe = []; - + const vm = this; + vm.openBlock = null; vm.showSampleDataCTA = false; @@ -56,6 +57,7 @@ if (blockGroupModel.value == null) { blockGroupModel.value = []; } + vm.blockGroups = blockGroupModel.value; if (!$scope.model.value) { @@ -87,6 +89,7 @@ } } } + unsubscribe.push(eventsService.on("editors.documentType.saved", updateUsedElementTypes)); function removeReferencesToElementTypeKey(contentElementTypeKey) { @@ -264,7 +267,7 @@ vm.openBlockOverlay = function (block, openAreas) { var elementType = vm.getElementTypeByKey(block.contentElementTypeKey); - + if (elementType) { localizationService.localize("blockEditor_blockConfigurationOverlayTitle", [elementType.name]).then(function (data) { @@ -356,6 +359,7 @@ }); } } + dataTypeResource.getAll().then(function(dataTypes) { if (dataTypes.filter(x => x.alias === "Umbraco.BlockGrid").length === 0) { vm.showSampleDataCTA = true; diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/ObjectExtensionsTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/ObjectExtensionsTests.cs index dc87f7094c..bfbe581f2e 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/ObjectExtensionsTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/CoreThings/ObjectExtensionsTests.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading; +using Microsoft.Extensions.Primitives; using NUnit.Framework; using Umbraco.Cms.Core.PropertyEditors; using Umbraco.Cms.Tests.Common.TestHelpers; @@ -281,6 +282,56 @@ public class ObjectExtensionsTests Assert.AreEqual(new DateTime(2016, 6, 7), conv.Result); } + [TestCase("d72f12a9-29db-42b4-9ffb-25a3ba4dcef5")] + [TestCase("D72F12A9-29DB-42B4-9FFB-25A3BA4DCEF5")] + public void CanConvertToGuid(string guidValue) + { + var conv = guidValue.TryConvertTo(); + Assert.IsTrue(conv); + Assert.AreEqual(Guid.Parse(guidValue), conv.Result); + } + + [TestCase("d72f12a9-29db-42b4-9ffb-25a3ba4dcef5")] + [TestCase("D72F12A9-29DB-42B4-9FFB-25A3BA4DCEF5")] + public void CanConvertToNullableGuid(string guidValue) + { + var conv = guidValue.TryConvertTo(); + Assert.IsTrue(conv); + Assert.AreEqual(Guid.Parse(guidValue), conv.Result); + } + + [TestCase("d72f12a9-29db-42b4-9ffb-25a3ba4dcef5")] + [TestCase("D72F12A9-29DB-42B4-9FFB-25A3BA4DCEF5")] + public void CanConvertStringValuesToNullableGuid(string guidValue) + { + StringValues stringValues = guidValue; + var conv = stringValues.TryConvertTo(); + Assert.IsTrue(conv); + Assert.AreEqual(Guid.Parse(guidValue), conv.Result); + } + + [TestCase(10)] + [TestCase(0)] + [TestCase(-10)] + [TestCase(int.MinValue)] + [TestCase(int.MaxValue)] + public void CanConvertStringValuesToInt(int intValue) + { + StringValues stringValues = intValue.ToString(); + var conv = stringValues.TryConvertTo(); + Assert.IsTrue(conv); + Assert.AreEqual(intValue, conv.Result); + } + + [Test] + public void CanConvertStringValuesToString() + { + StringValues stringValues = "This is a string"; + var conv = stringValues.TryConvertTo(); + Assert.IsTrue(conv); + Assert.AreEqual("This is a string", conv.Result); + } + [Test] public void Value_Editor_Can_Convert_Decimal_To_Decimal_Clr_Type() {