Skip to content

Commit

Permalink
Revert "Fixed copy preserving sort order (umbraco#10091)"
Browse files Browse the repository at this point in the history
This reverts commit 26d11a8.
  • Loading branch information
nul800sebastiaan authored and nzdev committed May 5, 2021
1 parent 767d1bb commit 640dc9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
10 changes: 5 additions & 5 deletions src/Umbraco.Core/Services/Implement/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ private void PerformScheduledPublishingExpiration(DateTime date, List<PublishRes

var result = CommitDocumentChangesInternal(scope, d, saveEventArgs, allLangs.Value, d.WriterId);
if (result.Success == false)
Logger.Error<ContentService, int, PublishResultType>(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
Logger.Error<ContentService,int,PublishResultType>(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
results.Add(result);

}
Expand Down Expand Up @@ -2201,7 +2201,7 @@ public IContent Copy(IContent content, int parentId, bool relateToOriginal, bool
while (page * pageSize < total)
{
var descendants = GetPagedDescendants(content.Id, page++, pageSize, out total);
foreach (var descendant in descendants.OrderBy(x => x.Level).ThenBy(y => y.SortOrder))
foreach (var descendant in descendants)
{
// if parent has not been copied, skip, else gets its copy id
if (idmap.TryGetValue(descendant.ParentId, out parentId) == false) continue;
Expand Down Expand Up @@ -2420,7 +2420,7 @@ public ContentDataIntegrityReport CheckDataIntegrity(ContentDataIntegrityReportO
if (report.FixedIssues.Count > 0)
{
//The event args needs a content item so we'll make a fake one with enough properties to not cause a null ref
var root = new Content("root", -1, new ContentType(-1)) { Id = -1, Key = Guid.Empty };
var root = new Content("root", -1, new ContentType(-1)) {Id = -1, Key = Guid.Empty};
scope.Events.Dispatch(TreeChanged, this, new TreeChange<IContent>.EventArgs(new TreeChange<IContent>(root, TreeChangeTypes.RefreshAll)));
}

Expand Down Expand Up @@ -3169,7 +3169,7 @@ public OperationResult Rollback(int id, int versionId, string culture = "*", int
if (rollbackSaveResult.Success == false)
{
//Log the error/warning
Logger.Error<ContentService, int, int, int>("User '{UserId}' was unable to rollback content '{ContentId}' to version '{VersionId}'", userId, id, versionId);
Logger.Error<ContentService,int,int,int>("User '{UserId}' was unable to rollback content '{ContentId}' to version '{VersionId}'", userId, id, versionId);
}
else
{
Expand All @@ -3178,7 +3178,7 @@ public OperationResult Rollback(int id, int versionId, string culture = "*", int
scope.Events.Dispatch(RolledBack, this, rollbackEventArgs);

//Logging & Audit message
Logger.Info<ContentService, int, int, int>("User '{UserId}' rolled back content '{ContentId}' to version '{VersionId}'", userId, id, versionId);
Logger.Info<ContentService,int,int,int>("User '{UserId}' rolled back content '{ContentId}' to version '{VersionId}'", userId, id, versionId);
Audit(AuditType.RollBack, userId, id, $"Content '{content.Name}' was rolled back to version '{versionId}'");
}

Expand Down
26 changes: 0 additions & 26 deletions src/Umbraco.Tests/Services/ContentServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2082,32 +2082,6 @@ public void Can_Copy_Content_With_Tags()
Assert.AreEqual("world", copiedTags[1].Text);
}

[Test]
public void Copy_Recursive_Preserves_Sort_Order()
{
// Arrange
var contentService = ServiceContext.ContentService;
var temp = contentService.GetById(NodeDto.NodeIdSeed + 2);
Assert.AreEqual("Home", temp.Name);
Assert.AreEqual(3, contentService.CountChildren(temp.Id));
var reversedChildren = contentService.GetPagedChildren(temp.Id, 0, 10, out var total1).Reverse().ToArray();
contentService.Sort(reversedChildren);

// Act
var copy = contentService.Copy(temp, temp.ParentId, false, true, Constants.Security.SuperUserId);
var content = contentService.GetById(NodeDto.NodeIdSeed + 2);

// Assert
Assert.That(copy, Is.Not.Null);
Assert.That(copy.Id, Is.Not.EqualTo(content.Id));
Assert.AreNotSame(content, copy);
Assert.AreEqual(3, contentService.CountChildren(copy.Id));

var copiedChildren = contentService.GetPagedChildren(copy.Id, 0, 10, out var total2).OrderBy(c => c.SortOrder).ToArray();
Assert.AreEqual(reversedChildren.First().Name, copiedChildren.First().Name);
Assert.AreEqual(reversedChildren.Last().Name, copiedChildren.Last().Name);
}

[Test]
public void Can_Rollback_Version_On_Content()
{
Expand Down

0 comments on commit 640dc9f

Please sign in to comment.