When deleting terms from a Hierarchy you can delete a term from the middle and orphan children records in the database.

Steps to reproduce.
1) Create vocabulary with single hierarchy
2) Create term 1
3) Create term 2 with parent of term 1
4) Create term 3 with parent of term 2
5) Delete term 2

Now in the database term 3 still exists, but is labeled with a parent of term 2 even though term 2 no longer exists. This makes it impossible to edit or delete term 3 in the admin screens.

When deleting terms with children all children's parents should get set to the deleted terms parent or if the child has no other parents then the child should be deleted as well.

CommentFileSizeAuthor
#3 drupal_722.64 KBJeremy
#2 drupal_691.83 KBJeremy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

the proposed resolution sounds OK as long as we tell the user on the Confirmation page exactly what is going to happen.

Jeremy’s picture

FileSize
1.83 KB

Here's a patch to implement this, recursively deleting terms and all their children. While testing I realized this has a side affect that probably needs to be resolved. To explain the remaining issue, imagine the following hierarchy:

       one
      /   \
    two   dos
   /   \ /  \
 three  3   tres

With this patch, deleting the term "two" will also delete "three" and "3". The term "three" should be deleted, but obviously "3" should not.

Jeremy’s picture

FileSize
2.64 KB

Okay, this patch cleans up all orphans and only orphans.

Dries’s picture

Priority: Critical » Normal

I rewrote this patch (the code is a lot shorter now) and committed it to HEAD.

Anonymous’s picture