From a5ba32bfd7478f44a0aff3c9c0fcdad08fe51d96 Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com> Date: Fri, 7 Jul 2023 15:23:32 +0300 Subject: [PATCH 1/3] Store tags as text (instead of nvarchar) (#14510) * Migrate tags from NVarchar To NText * Cleanup --- .../Migrations/Upgrade/UmbracoPlan.cs | 4 ++ .../MigrateTagsFromNVarcharToNText.cs | 46 +++++++++++++++++++ .../PropertyEditors/TagsPropertyEditor.cs | 3 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index 62a37a8e98..aaffb07839 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -6,6 +6,7 @@ using Umbraco.Cms.Infrastructure.Migrations.Upgrade.Common; using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_0_0; using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_2_0; using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_5_0; +using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_7_0; using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_8_0_0; using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_8_0_1; using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_8_1_0; @@ -303,5 +304,8 @@ public class UmbracoPlan : MigrationPlan // to 10.5.0 To("{83AF7945-DADE-4A02-9041-F3F6EBFAC319}"); + + // to 10.7.0 + To("{EF93F398-1385-4F07-808A-D3C518984442}"); } } diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs new file mode 100644 index 0000000000..462e3772fa --- /dev/null +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs @@ -0,0 +1,46 @@ +using NPoco; +using Umbraco.Cms.Core; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Infrastructure.Persistence; +using Umbraco.Cms.Infrastructure.Persistence.Dtos; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_7_0; + +public class MigrateTagsFromNVarcharToNText : MigrationBase +{ + public MigrateTagsFromNVarcharToNText(IMigrationContext context) + : base(context) + { + } + + protected override void Migrate() + { + // Firstly change the storage type for the Umbraco.Tags property editor + Sql updateDbTypeForTagsQuery = Database.SqlContext.Sql() + .Update(x => x.Set(dt => dt.DbType, ValueStorageType.Ntext.ToString())) + .Where(dt => dt.EditorAlias == Constants.PropertyEditors.Aliases.Tags); + + Database.Execute(updateDbTypeForTagsQuery); + + // Then migrate the data from "varcharValue" column to "textValue" + Sql tagsDataTypeIdQuery = Database.SqlContext.Sql() + .Select(dt => dt.NodeId) + .From() + .Where(dt => dt.EditorAlias == Constants.PropertyEditors.Aliases.Tags); + + Sql tagsPropertyTypeIdQuery = Database.SqlContext.Sql() + .Select(pt => pt.Id) + .From() + .WhereIn(pt => pt.DataTypeId, tagsDataTypeIdQuery); + + Sql updatePropertyDataColumnsQuery = Database.SqlContext.Sql() + .Update() + .Append("SET textValue = varcharValue, varcharValue = null") + .WhereIn(pd => pd.PropertyTypeId, tagsPropertyTypeIdQuery) + .Where(pd => pd.TextValue == null) + .Where(pd => pd.VarcharValue != null); + + Database.Execute(updatePropertyDataColumnsQuery); + } +} diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs index 6f82c8ab3c..99ae8f378a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs @@ -25,7 +25,8 @@ namespace Umbraco.Cms.Core.PropertyEditors; "Tags", "tags", Icon = "icon-tags", - ValueEditorIsReusable = true)] + ValueEditorIsReusable = true, + ValueType = ValueTypes.Text)] public class TagsPropertyEditor : DataEditor { private readonly IEditorConfigurationParser _editorConfigurationParser; From 82eae48d098b9deecbdf86cf288b2b18020e1fed Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Thu, 13 Jul 2023 06:03:39 +0200 Subject: [PATCH 2/3] Merge pull request from GHSA-h8wc-r4jh-mg7m * Don't login after install * Fail the install if database is not created --------- Co-authored-by: Zeegaan Co-authored-by: Nikolaj --- .../Runtime/RuntimeState.cs | 2 +- .../Install/InstallApiController.cs | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs b/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs index ec1cfc5d6e..8731f7acc8 100644 --- a/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs @@ -213,7 +213,7 @@ public class RuntimeState : IRuntimeState if (_globalSettings.Value.InstallMissingDatabase || _databaseProviderMetadata.CanForceCreateDatabase(_databaseFactory)) { // ok to install on a configured but missing database - Level = RuntimeLevel.Install; + Level = RuntimeLevel.BootFailed; Reason = RuntimeLevelReason.InstallMissingDatabase; return; } diff --git a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs index 555c14ff96..b710933791 100644 --- a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs @@ -1,5 +1,6 @@ using System.Reflection; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Umbraco.Cms.Core; @@ -25,8 +26,6 @@ namespace Umbraco.Cms.Web.BackOffice.Install; [Area(Constants.Web.Mvc.InstallArea)] public class InstallApiController : ControllerBase { - private readonly IBackOfficeSignInManager _backOfficeSignInManager; - private readonly IBackOfficeUserManager _backOfficeUserManager; private readonly DatabaseBuilder _databaseBuilder; private readonly InstallStatusTracker _installStatusTracker; private readonly InstallStepCollection _installSteps; @@ -34,6 +33,7 @@ public class InstallApiController : ControllerBase private readonly IProfilingLogger _proflog; private readonly IRuntime _runtime; + [Obsolete("Use the constructor without IBackOfficeUserManager & IBackOfficeSignInManager instead, scheduled for removal in v14")] public InstallApiController( DatabaseBuilder databaseBuilder, IProfilingLogger proflog, @@ -44,14 +44,25 @@ public class InstallApiController : ControllerBase IRuntime runtime, IBackOfficeUserManager backOfficeUserManager, IBackOfficeSignInManager backOfficeSignInManager) + : this(databaseBuilder, proflog, logger, installHelper, installSteps, installStatusTracker, runtime) + { + } + + [ActivatorUtilitiesConstructor] + public InstallApiController( + DatabaseBuilder databaseBuilder, + IProfilingLogger proflog, + ILogger logger, + InstallHelper installHelper, + InstallStepCollection installSteps, + InstallStatusTracker installStatusTracker, + IRuntime runtime) { _databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder)); _proflog = proflog ?? throw new ArgumentNullException(nameof(proflog)); _installSteps = installSteps; _installStatusTracker = installStatusTracker; _runtime = runtime; - _backOfficeUserManager = backOfficeUserManager; - _backOfficeSignInManager = backOfficeSignInManager; InstallHelper = installHelper; _logger = logger; } @@ -88,16 +99,8 @@ public class InstallApiController : ControllerBase [HttpPost] public async Task CompleteInstall() { - RuntimeLevel levelBeforeRestart = _runtime.State.Level; - await _runtime.RestartAsync(); - if (levelBeforeRestart == RuntimeLevel.Install) - { - BackOfficeIdentityUser identityUser = await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); - _backOfficeSignInManager.SignInAsync(identityUser, false); - } - return NoContent(); } From c12cce6d8c077f49a2ecde4f879ed42f6567f072 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 14 Jul 2023 09:27:02 +0200 Subject: [PATCH 3/3] Fixes an incorrect property name used for generating JSON schema. (#14542) --- src/JsonSchema/AppSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonSchema/AppSettings.cs b/src/JsonSchema/AppSettings.cs index e1a6d619ec..717f826859 100644 --- a/src/JsonSchema/AppSettings.cs +++ b/src/JsonSchema/AppSettings.cs @@ -88,7 +88,7 @@ namespace JsonSchema public HelpPageSettings? HelpPage { get; set; } - public InstallDefaultDataSettings? DefaultDataCreation { get; set; } + public InstallDefaultDataSettings? InstallDefaultData { get; set; } public DataTypesSettings? DataTypes { get; set; }