U4-7861 - Moving a ContentType graph breaks parent/child relationships

Created by Stephan 29 Jan 2016, 12:11:43 Updated by Shannon Deminick 03 Feb 2016, 12:59:09

After commits 73f1458190b4a98470cdc0fa4de5f46159ca3e97 and ce3028446b154beaf6b92a19d873af0cc8c36aec the code in ContentTypeBaseRepository.Move now looks like:

//update all descendants, update in order of level var descendants = this.GetByQuery( new Query().Where(type => type.Path.StartsWith(origPath + ",")));

        var lastParent = toMove;
        foreach (var descendant in descendants.OrderBy(x => x.Level))
        {
            moveInfo.Add(new MoveEventInfo<TEntity>(descendant, descendant.Path, descendant.ParentId));

            descendant.ParentId = lastParent.Id;
            descendant.Path = string.Concat(lastParent.Path, ",", descendant.Id);

            //schedule it for updating in the transaction
            AddOrUpdate(descendant);

            lastParent = descendant;
        }

This does not work for graphs. Ie if the structure is that toMove has children child1 and child2, *when child1 is processed, lastParent == toMove and child1.ParentId is set to toMove.Id :: correct *then lastParent is set to child1 *when child2 is processed, lastParent == child1 and child2.ParentId is set to child1.Id :: wrong

Managing paths should be done in the repository, not in the service (see also what we do for content items) but that has other issues with events...

Comments

Shannon Deminick 01 Feb 2016, 13:09:16

Need to determine if this affects 7.3.6 or not and reassign if needed


Stephan 02 Feb 2016, 13:01:45

Does ''not'' affect 7.3 - only 7.4.


Stephan 02 Feb 2016, 15:40:32

PR: https://github.com/umbraco/Umbraco-CMS/pull/1085


Stephan 02 Feb 2016, 15:41:24

Test: create a tree of content types (multiple levels, multiple children) - move the top content type around - check in database: all paths & levels & parentID should be OK


Shannon Deminick 03 Feb 2016, 11:13:51

I've merged this in, it all seems to work but I couldn't really replicate the issue to begin with.


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.4.0

Due in version: 7.4.0

Sprint: Sprint 8

Story Points:

Cycle: