From 1be874c78181d8f4c50123245adda51c842b18bf Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Wed, 6 May 2026 11:48:30 +0200 Subject: [PATCH 1/5] Removed obsoleted property Updated methods that were still using it Obsoleted constructors that were still setting the value. --- src/Umbraco.Core/Events/MoveEventInfo.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Core/Events/MoveEventInfo.cs b/src/Umbraco.Core/Events/MoveEventInfo.cs index 30c7e3b4c242..d81df7618b13 100644 --- a/src/Umbraco.Core/Events/MoveEventInfo.cs +++ b/src/Umbraco.Core/Events/MoveEventInfo.cs @@ -13,10 +13,10 @@ public class MoveEventInfo : MoveEventInfoBase /// The original path of the entity. /// The identifier of the new parent. /// The unique identifier of the new parent. + [Obsolete("Use the overload without the newParentId parameter instead. Scheduled for removal in v19.")] public MoveEventInfo(TEntity entity, string originalPath, int newParentId, Guid? newParentKey) : base(entity, originalPath) { - NewParentId = newParentId; NewParentKey = newParentKey; } @@ -26,15 +26,23 @@ public MoveEventInfo(TEntity entity, string originalPath, int newParentId, Guid? /// The entity being moved. /// The original path of the entity. /// The identifier of the new parent. - public MoveEventInfo(TEntity entity, string originalPath, int newParentId) : this(entity, originalPath, newParentId, null) + [Obsolete("Use the overload with the newParentKey parameter instead. Scheduled for removal in v19.")] + public MoveEventInfo(TEntity entity, string originalPath, int newParentId) + : this(entity, originalPath, newParentId, null) { } /// - /// Gets or sets the identifier of the new parent. + /// Initializes a new instance of the class. /// - [Obsolete("Please use NewParentKey instead. Scheduled for removal in Umbraco 18.")] - public int NewParentId { get; set; } + /// The entity being moved. + /// The original path of the entity. + /// The unique identifier of the new parent. + public MoveEventInfo(TEntity entity, string originalPath, Guid? newParentKey) + : base(entity, originalPath) + { + NewParentKey = newParentKey; + } /// /// Gets the unique identifier of the new parent. @@ -57,7 +65,7 @@ public MoveEventInfo(TEntity entity, string originalPath, int newParentId) : thi /// /// The other instance to compare. /// true if the instances are equal; otherwise, false. - public bool Equals(MoveEventInfo? other) => NewParentId == other?.NewParentId && NewParentKey == other.NewParentKey && base.Equals(other); + public bool Equals(MoveEventInfo? other) => NewParentKey == other?.NewParentKey && base.Equals(other); /// public override int GetHashCode() @@ -67,7 +75,7 @@ public override int GetHashCode() var hashCode = Entity is not null ? EqualityComparer.Default.GetHashCode(Entity) : base.GetHashCode(); - hashCode = (hashCode * 397) ^ NewParentId; + hashCode = (hashCode * 397) ^ NewParentKey.GetHashCode(); hashCode = (hashCode * 397) ^ OriginalPath.GetHashCode(); return hashCode; } From 3e6003359d999b0ba7953f249502254d84486092 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Wed, 6 May 2026 11:48:43 +0200 Subject: [PATCH 2/5] Updated code that were using the now obsoleted constructors --- src/Umbraco.Core/Services/ContentService.cs | 2 +- src/Umbraco.Core/Services/DataTypeService.cs | 2 +- src/Umbraco.Core/Services/DictionaryItemService.cs | 2 +- src/Umbraco.Core/Services/ElementContainerService.cs | 4 ++-- src/Umbraco.Core/Services/ElementEditingService.cs | 4 ++-- .../Repositories/Implement/ContentTypeRepositoryBase.cs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index cf94e2e9d32d..576e4d288cde 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1192,7 +1192,7 @@ public OperationResult Move(IContent content, int parentId, int userId = Constan } TryGetParentKey(parentId, out Guid? parentKey); - var moveEventInfo = new MoveEventInfo(content, content.Path, parentId, parentKey); + var moveEventInfo = new MoveEventInfo(content, content.Path, parentKey); var movingNotification = new ContentMovingNotification(moveEventInfo, eventMessages); if (scope.Notifications.PublishCancelable(movingNotification)) diff --git a/src/Umbraco.Core/Services/DataTypeService.cs b/src/Umbraco.Core/Services/DataTypeService.cs index f6caec019f14..b86993fccb7b 100644 --- a/src/Umbraco.Core/Services/DataTypeService.cs +++ b/src/Umbraco.Core/Services/DataTypeService.cs @@ -177,7 +177,7 @@ public async Task> MoveAsync(IDataTy return Attempt.SucceedWithStatus(DataTypeOperationStatus.Success, toMove); } - var moveEventInfo = new MoveEventInfo(toMove, toMove.Path, parentId, containerKey); + var moveEventInfo = new MoveEventInfo(toMove, toMove.Path, containerKey); var movingDataTypeNotification = new DataTypeMovingNotification(moveEventInfo, eventMessages); if (scope.Notifications.PublishCancelable(movingDataTypeNotification)) { diff --git a/src/Umbraco.Core/Services/DictionaryItemService.cs b/src/Umbraco.Core/Services/DictionaryItemService.cs index f5199b68f960..0c408476b13b 100644 --- a/src/Umbraco.Core/Services/DictionaryItemService.cs +++ b/src/Umbraco.Core/Services/DictionaryItemService.cs @@ -294,7 +294,7 @@ public async Task> MoveA dictionaryItem.ParentId = parentId; EventMessages eventMessages = EventMessagesFactory.Get(); - var moveEventInfo = new MoveEventInfo(dictionaryItem, string.Empty, parent?.Id ?? Constants.System.Root, parentId); + var moveEventInfo = new MoveEventInfo(dictionaryItem, string.Empty, parentId); var movingNotification = new DictionaryItemMovingNotification(moveEventInfo, eventMessages); if (await scope.Notifications.PublishCancelableAsync(movingNotification)) { diff --git a/src/Umbraco.Core/Services/ElementContainerService.cs b/src/Umbraco.Core/Services/ElementContainerService.cs index 3756882bc3c7..23a8fe11f8b2 100644 --- a/src/Umbraco.Core/Services/ElementContainerService.cs +++ b/src/Umbraco.Core/Services/ElementContainerService.cs @@ -181,12 +181,12 @@ private async Task> HandleMoveAsync( : EntityContainerOperationStatus.Success, (cont, eventMessages) => { - var moveEventInfo = new MoveEventInfo(cont, originalPath, parentId, parentKey); + var moveEventInfo = new MoveEventInfo(cont, originalPath, parentKey); return new EntityContainerMovingNotification(moveEventInfo, eventMessages); }, (cont, eventMessages) => { - var moveEventInfo = new MoveEventInfo(cont, originalPath, parentId, parentKey); + var moveEventInfo = new MoveEventInfo(cont, originalPath, parentKey); return new EntityContainerMovedNotification(moveEventInfo, eventMessages); }); diff --git a/src/Umbraco.Core/Services/ElementEditingService.cs b/src/Umbraco.Core/Services/ElementEditingService.cs index f4bd7ad09002..fba090438b52 100644 --- a/src/Umbraco.Core/Services/ElementEditingService.cs +++ b/src/Umbraco.Core/Services/ElementEditingService.cs @@ -316,12 +316,12 @@ private async Task> HandleElementMoveAsyn userKey, (elem, eventMessages) => { - var moveEventInfo = new MoveEventInfo(elem, originalPath, parentId, containerKey); + var moveEventInfo = new MoveEventInfo(elem, originalPath, containerKey); return new ElementMovingNotification(moveEventInfo, eventMessages); }, (elem, eventMessages) => { - var moveEventInfo = new MoveEventInfo(elem, originalPath, parentId, containerKey); + var moveEventInfo = new MoveEventInfo(elem, originalPath, containerKey); return new ElementMovedNotification(moveEventInfo, eventMessages); }); diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs index 7c1af544a51d..432a81cc4975 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs @@ -127,7 +127,7 @@ public IEnumerable> Move(TEntity moving, EntityContainer? } // track moved entities - var moveInfo = new List> { new(moving, moving.Path, parentId, parentKey) }; + var moveInfo = new List> { new(moving, moving.Path, parentKey) }; // get the level delta (old pos to new pos) var levelDelta = container == null From 51a6c4a4119cd2ad751225ec017b8c549e295c67 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Wed, 6 May 2026 13:19:41 +0200 Subject: [PATCH 3/5] More obsoleted constructor fixes --- src/Umbraco.Core/Events/MoveEventInfo.cs | 2 +- src/Umbraco.Core/Services/ContentService.cs | 2 +- .../Services/ContentTypeServiceBase{TRepository,TItem}.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Events/MoveEventInfo.cs b/src/Umbraco.Core/Events/MoveEventInfo.cs index d81df7618b13..d526d67b3779 100644 --- a/src/Umbraco.Core/Events/MoveEventInfo.cs +++ b/src/Umbraco.Core/Events/MoveEventInfo.cs @@ -28,7 +28,7 @@ public MoveEventInfo(TEntity entity, string originalPath, int newParentId, Guid? /// The identifier of the new parent. [Obsolete("Use the overload with the newParentKey parameter instead. Scheduled for removal in v19.")] public MoveEventInfo(TEntity entity, string originalPath, int newParentId) - : this(entity, originalPath, newParentId, null) + : this(entity, originalPath, null) { } diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 576e4d288cde..be1e5ab96248 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1226,7 +1226,7 @@ public OperationResult Move(IContent content, int parentId, int userId = Constan .Select(x => { TryGetParentKey(x.Item1.ParentId, out Guid? itemParentKey); - return new MoveEventInfo(x.Item1, x.Item2, x.Item1.ParentId, itemParentKey); + return new MoveEventInfo(x.Item1, x.Item2, itemParentKey); }) .ToArray(); diff --git a/src/Umbraco.Core/Services/ContentTypeServiceBase{TRepository,TItem}.cs b/src/Umbraco.Core/Services/ContentTypeServiceBase{TRepository,TItem}.cs index e4ef3d6126b8..6fb55b4bde20 100644 --- a/src/Umbraco.Core/Services/ContentTypeServiceBase{TRepository,TItem}.cs +++ b/src/Umbraco.Core/Services/ContentTypeServiceBase{TRepository,TItem}.cs @@ -1136,7 +1136,7 @@ public void Delete(IEnumerable items, int userId = Constants.Security.Sup var moveInfo = new List>(); using (ICoreScope scope = ScopeProvider.CreateCoreScope()) { - var moveEventInfo = new MoveEventInfo(toMove, toMove.Path, containerId.Value); + var moveEventInfo = new MoveEventInfo(toMove, toMove.Path, containerKey); MovingNotification movingNotification = GetMovingNotification(moveEventInfo, eventMessages); if (scope.Notifications.PublishCancelable(movingNotification)) { From 8d1fdb23a91ac4527959a19dd9e31fde2c79a6ea Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Wed, 6 May 2026 14:09:41 +0200 Subject: [PATCH 4/5] Update unittests Removed obsolete (parentId) cases and updated constructors --- .../Umbraco.Core/Events/MoveEventInfoTests.cs | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Events/MoveEventInfoTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Events/MoveEventInfoTests.cs index fc4c9c808137..61493334ebcd 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Events/MoveEventInfoTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Events/MoveEventInfoTests.cs @@ -28,28 +28,27 @@ public void Can_Equate_Move_To_Recyclebin_Move_Event_Infos_All_Params_Null_Or_Em [Test] public void Can_Equate_Move_Event_Infos_Parent_Key_Null() { - var moveEvent = new MoveEventInfo("entity", "path", 123, null); - var moveEventTwo = new MoveEventInfo("entity", "path", 123, null); + var moveEvent = new MoveEventInfo("entity", "path", null); + var moveEventTwo = new MoveEventInfo("entity", "path", null); Assert.IsTrue(moveEvent.Equals(moveEventTwo)); } [Test] public void Can_Equate_Move_Event_Infos_All_Params_Null_Or_Empty() { - var moveEvent = new MoveEventInfo(string.Empty, string.Empty, 0, null); - var moveEventTwo = new MoveEventInfo(string.Empty, string.Empty, 0, null); + var moveEvent = new MoveEventInfo(string.Empty, string.Empty, null); + var moveEventTwo = new MoveEventInfo(string.Empty, string.Empty, null); Assert.IsTrue(moveEvent.Equals(moveEventTwo)); } - [TestCase(123, "entity", "", "063897F1-194A-4C42-B406-CA80DBC12968", false)] - [TestCase(123, "", "path", "063897F1-194A-4C42-B406-CA80DBC12968", false)] - [TestCase(12, "entity", "path", "063897F1-194A-4C42-B406-CA80DBC12968", false)] - [TestCase(123, "entity", "path", "C6D6EA3E-C2B0-483F-B772-2F4D8BBF5027", false)] - [TestCase(123, "entity", "path", "063897F1-194A-4C42-B406-CA80DBC12968", true)] - public void Can_Equate_Move_Event_Infos(int parentId, string entity, string originalPath, Guid parentKey, bool expectedResult) + [TestCase("entity", "", "063897F1-194A-4C42-B406-CA80DBC12968", false)] + [TestCase("", "path", "063897F1-194A-4C42-B406-CA80DBC12968", false)] + [TestCase("entity", "path", "C6D6EA3E-C2B0-483F-B772-2F4D8BBF5027", false)] + [TestCase("entity", "path", "063897F1-194A-4C42-B406-CA80DBC12968", true)] + public void Can_Equate_Move_Event_Infos(string entity, string originalPath, Guid parentKey, bool expectedResult) { - var moveEvent = new MoveEventInfo(entity, originalPath, parentId, parentKey); - var moveEventTwo = new MoveEventInfo("entity", "path", 123, new Guid("063897F1-194A-4C42-B406-CA80DBC12968")); + var moveEvent = new MoveEventInfo(entity, originalPath, parentKey); + var moveEventTwo = new MoveEventInfo("entity", "path", new Guid("063897F1-194A-4C42-B406-CA80DBC12968")); Assert.AreEqual(expectedResult, moveEvent.Equals(moveEventTwo)); } } From 922bfaf5880a8acaebff55067ae4ffa8ad951d35 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Wed, 6 May 2026 14:36:56 +0200 Subject: [PATCH 5/5] DRY up constructor --- src/Umbraco.Core/Events/MoveEventInfo.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Events/MoveEventInfo.cs b/src/Umbraco.Core/Events/MoveEventInfo.cs index d526d67b3779..84cfb3c0c399 100644 --- a/src/Umbraco.Core/Events/MoveEventInfo.cs +++ b/src/Umbraco.Core/Events/MoveEventInfo.cs @@ -15,9 +15,8 @@ public class MoveEventInfo : MoveEventInfoBase /// The unique identifier of the new parent. [Obsolete("Use the overload without the newParentId parameter instead. Scheduled for removal in v19.")] public MoveEventInfo(TEntity entity, string originalPath, int newParentId, Guid? newParentKey) - : base(entity, originalPath) + : this(entity, originalPath, newParentKey) { - NewParentKey = newParentKey; } ///