Can two groups have the same Left or Right values?

Created on 13 January 2022, almost 3 years ago
Updated 2 June 2023, over 1 year ago

According to the Nested Set model, it shouldn't be possible to have the same left/right values for a tree member.
Yet, in my case, after adding and deleting groups, I get to the below state.

In my case, a Factory is a parent group type for HR and Development group types.
Note that both groups 23 and 24 have a similar value for left.
In previous versions of my DB I had more duplicate entries.

Is this a bug or a valid situation?

SELECT t.bundle, t.entity_id, t.subgroup_tree_value, l.subgroup_left_value, r.subgroup_right_value
    -> FROM group__subgroup_tree AS t LEFT JOIN group__subgroup_left AS l ON t.entity_id=l.entity_id
    -> RIGHT JOIN group__subgroup_right AS r ON t.entity_id=r.entity_id;

+-------------+-----------+---------------------+---------------------+----------------------+
| bundle      | entity_id | subgroup_tree_value | subgroup_left_value | subgroup_right_value |
+-------------+-----------+---------------------+---------------------+----------------------+
| factory     |         1 |                   1 |                   1 |                    6 |
| factory     |        11 |                  11 |                   1 |                   30 |
| HR          |        12 |                  11 |                   2 |                    3 |
| development |        20 |                  11 |                   4 |                    5 |
| development |        21 |                  11 |                   6 |                    7 |
| HR          |        22 |                  11 |                   8 |                    9 |
| HR          |        23 |                  11 |                  10 |                   31 |
| HR          |        24 |                  11 |                  10 |                   11 |
| HR          |        25 |                  11 |                  12 |                   13 |
| HR          |        26 |                  11 |                  14 |                   15 |
| HR          |        27 |                  11 |                  16 |                   17 |
| development |        28 |                  11 |                  18 |                   19 |
| development |        29 |                  11 |                  20 |                   21 |
| HR          |        30 |                  11 |                  22 |                   23 |
| development |        31 |                  11 |                  24 |                   25 |
| HR          |        32 |                  11 |                  26 |                   27 |
| HR          |        33 |                  11 |                  28 |                   29 |
+-------------+-----------+---------------------+---------------------+----------------------+
πŸ› Bug report
Status

Active

Version

1.0

Component

Miscellaneous

Created by

πŸ‡«πŸ‡·France z.stolar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡±Netherlands Jan-E

    Could it be that you have revisions enabled and reverted one of the groups to an earlier revision? That might lead to a corrupted tree:
    See https://www.drupal.org/project/subgroup/issues/3281672#comment-14880993 πŸ› doAddLeaf & doRemoveLeaf: timestamp bug and scalability Fixed

  • πŸ‡ΊπŸ‡ΈUnited States aytee

    @Jan-E Would you be willing to share the script to rebuild trees from scratch?

    I'm encountering challenges when cloning a Group that is in a Tree.

  • πŸ‡³πŸ‡±Netherlands Jan-E

    Sorry, I overlooked this one. See https://gist.github.com/Jan-E/20218ef0b471756e0075287d3df761bc
    Very unedited and only applicable with our structure: project = tree, case = subgroup, session = subsubgroup.
    The idea is that you loop through the trees, loop through the subgroups below it, loop though the subsubgroups below the subgroups, start counting and formulate the queries to re-initialize all left & right values. With the argument tfr-rebuild-trees.php?execute=1 you execute all the queries.
    db_left and db_right are the values from the database, sb_left and sb_right is what they should be. If they differ the query will bolded. See screenshot, made on my iPad. With no differences, because it was a long time agon that I had a corrupt tree.

Production build 0.71.5 2024