Fix copy document with descendants onto self (#17661)

* Filter self out of descedants for self onto self copy

* Optimized code

---------

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Sven Geusens
2024-12-01 13:02:47 +01:00
committed by GitHub
parent 28756d449b
commit 21e3518a69
2 changed files with 49 additions and 0 deletions

View File

@@ -2699,6 +2699,13 @@ public class ContentService : RepositoryService, IContentService
GetPagedDescendants(content.Id, page++, pageSize, out total);
foreach (IContent descendant in descendants)
{
// when copying a branch into itself, the copy of a root would be seen as a descendant
// and would be copied again => filter it out.
if (descendant.Id == copy.Id)
{
continue;
}
// if parent has not been copied, skip, else gets its copy id
if (idmap.TryGetValue(descendant.ParentId, out parentId) == false)
{