diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index d2bdb6d785..af06c7e0ba 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1039,7 +1039,8 @@ namespace Umbraco.Core.Services }; //get descendents to process of the content item that is being moved to trash - must be done before changing the state below - var descendants = ignoreDescendants ? Enumerable.Empty() : GetDescendants(content).OrderByDescending(x => x.Level); + //must be processed with shallowest levels first + var descendants = ignoreDescendants ? Enumerable.Empty() : GetDescendants(content).OrderBy(x => x.Level); //Do the updates for this item var repository = RepositoryFactory.CreateContentRepository(uow); diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index fb2a410cc8..9f5ec811c9 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -1072,8 +1072,9 @@ namespace Umbraco.Core.Services new MoveEventInfo(media, originalPath, Constants.System.RecycleBinMedia) }; - //get descendents to process of the content item that is being moved to trash - must be done before changing the state below - var descendants = ignoreDescendants ? Enumerable.Empty() : GetDescendants(media).OrderByDescending(x => x.Level); + //get descendents to process of the content item that is being moved to trash - must be done before changing the state below, + //must be processed with shallowest levels first + var descendants = ignoreDescendants ? Enumerable.Empty() : GetDescendants(media).OrderBy(x => x.Level); //Do the updates for this item var repository = RepositoryFactory.CreateMediaRepository(uow); diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index d8c26e1abb..e360018104 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -1319,7 +1319,7 @@ namespace Umbraco.Tests.Services // Assert Assert.That(content.ParentId, Is.EqualTo(-20)); Assert.That(content.Trashed, Is.True); - Assert.That(descendants.Count(), Is.EqualTo(3)); + Assert.That(descendants.Count, Is.EqualTo(3)); Assert.That(descendants.Any(x => x.Path.Contains("-20") == false), Is.False); //Empty Recycle Bin