Deleting entities leaves obsolete EntityTag records
Steps to reproduce
- Create a contact
- Assign a tag to the contact
- (Permantently) Delete the contact
Expected result
The record in civicrm_entity_tag
for the contact-tag relationship should have been removed.
Actual result
The record in civicrm_entitiy_tag
for the contact-tag relationship retains and will never-ever be deleted.
Technical background
Since a FK constraint ON DELETE CASCADE
on the civicrm_entity_tag
table for all possible entity ID tables is not possible, also due to the aggregated identification (entity_table
and entity_id
), this should be done in code when deleting any entity that may be assigned a tag.