Tag tree broken for nested tags when the tags weren't created in the same order as they are nested
Overview
Commit a902f9f9 brakes the tag tree (in the add tag to contact dialog) for nested tags when the tags weren't created in the same order as they are nested.
This happens when a child tag that has itself children is moved under a newer parent tag.
Reproduction steps
- Go to civicrm/tag
- Add a new tag called "Isaac" to the tag tree
- Add a new tag called "Abraham" to the tag tree
- Add a new tag called "Jacob" to the tag tree
- Move the tag "Jacob" below "Isaac"
- Move the tag "Isaac" below "Abraham"
- Try to add the Tag Jacob to a contact (it will not show up).
The order of tag creation is important.
Current behaviour
The tag Jacob is not shown when trying to add it to a contact.
Expected behaviour
What should happen.
This is how it used to be and how it is after applying the fix:
Fix and cause of issue
If you uncomment $thisref['children'] = [];
in line 92 in file CRM/Core/BAO/Tag.php
everything works again as expected.
This error was introduced by commit a902f9f9.