From 1cf7d7ad2b9d191e6b0f565de65a379b3cae2b5a Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 1 Oct 2024 14:38:51 +0200 Subject: [PATCH] Fix document URL migration (split it in two) --- src/Umbraco.Core/Services/DocumentUrlService.cs | 2 +- .../Migrations/Upgrade/UmbracoPlan.cs | 1 + .../Upgrade/V_15_0_0/AddDocumentUrl.cs | 13 +++---------- .../Upgrade/V_15_0_0/RebuildDocumentUrls.cs | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/RebuildDocumentUrls.cs diff --git a/src/Umbraco.Core/Services/DocumentUrlService.cs b/src/Umbraco.Core/Services/DocumentUrlService.cs index b1496aaec7..1b69029fd4 100644 --- a/src/Umbraco.Core/Services/DocumentUrlService.cs +++ b/src/Umbraco.Core/Services/DocumentUrlService.cs @@ -170,7 +170,7 @@ public class DocumentUrlService : IDocumentUrlService using ICoreScope scope = _coreScopeProvider.CreateCoreScope(); scope.ReadLock(Constants.Locks.ContentTree); - IEnumerable documents = _documentRepository.GetMany(Array.Empty()); + IEnumerable documents = _documentRepository.GetMany(Array.Empty()); await CreateOrUpdateUrlSegmentsAsync(documents); diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index 459af0304e..5b09ef3fc2 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -99,6 +99,7 @@ public class UmbracoPlan : MigrationPlan // To 15.0.0 To("{7F4F31D8-DD71-4F0D-93FC-2690A924D84B}"); To("{1A8835EF-F8AB-4472-B4D8-D75B7C164022}"); + To("{3FE0FA2D-CF4F-4892-BA8D-E97D06E028DC}"); To("{6C04B137-0097-4938-8C6A-276DF1A0ECA8}"); To("{9D3CE7D4-4884-41D4-98E8-302EB6CB0CF6}"); To("{37875E80-5CDD-42FF-A21A-7D4E3E23E0ED}"); diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/AddDocumentUrl.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/AddDocumentUrl.cs index 84c158eb33..d1b70f034e 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/AddDocumentUrl.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/AddDocumentUrl.cs @@ -1,22 +1,15 @@ -using Umbraco.Cms.Core.Services; -using Umbraco.Cms.Infrastructure.Persistence.Dtos; +using Umbraco.Cms.Infrastructure.Persistence.Dtos; namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_15_0_0; [Obsolete("Remove in Umbraco 18.")] public class AddDocumentUrl : MigrationBase { - private readonly IDocumentUrlService _documentUrlService; - - public AddDocumentUrl(IMigrationContext context, IDocumentUrlService documentUrlService) + public AddDocumentUrl(IMigrationContext context) : base(context) { - _documentUrlService = documentUrlService; } protected override void Migrate() - { - Create.Table().Do(); - _documentUrlService.InitAsync(false, CancellationToken.None); - } + => Create.Table().Do(); } diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/RebuildDocumentUrls.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/RebuildDocumentUrls.cs new file mode 100644 index 0000000000..79b9a2596c --- /dev/null +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/RebuildDocumentUrls.cs @@ -0,0 +1,16 @@ +using Umbraco.Cms.Core.Services; + +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_15_0_0; + +[Obsolete("Remove in Umbraco 18.")] +public class RebuildDocumentUrls : MigrationBase +{ + private readonly IDocumentUrlService _documentUrlService; + + public RebuildDocumentUrls(IMigrationContext context, IDocumentUrlService documentUrlService) + : base(context) => + _documentUrlService = documentUrlService; + + protected override void Migrate() + => _documentUrlService.InitAsync(false, CancellationToken.None).GetAwaiter().GetResult(); +}