diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index d02fb85db4dc..50da7550b7ae 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -89,12 +89,18 @@ public function buildTree($usedFor = NULL, $excludeHidden = FALSE) { $thisref['name'] = $dao->name; $thisref['description'] = $dao->description; $thisref['is_selectable'] = $dao->is_selectable; - $thisref['children'] = []; - + if (!isset($thisref['children'])) { + $thisref['children'] = []; + } if (!$dao->parent_id) { $this->tree[$dao->id] = &$thisref; } else { + if (!isset($refs[$dao->parent_id])) { + $refs[$dao->parent_id] = array( + 'children' => [] + ); + } $refs[$dao->parent_id]['children'][$dao->id] = &$thisref; } }