Deleting a smart group does not delete the saved search
Steps to recreate:
- Create a search for name like 'smith'
- Use the search results to create a smart group 'Smiths'
- In the DB new rows in _saved_search, new entry in _group
- Delete the group 'Smiths'
- In the DB, the _group row as been deleted, but the _saved_search row is still there
I picked up on this because saved searches with 'old' custom fields were coming out on the system checklist report for smart groups with disabled/deleted fields. But because they are not associated with a group anymore, the entries are blank:
Discussion points:
1 - We could fix the query that's building these alerts to only list active groups, excluding 'orphaned' saved searches, but it might be better to...
2 - Are saved_search entries used anywhere apart from smart groups? If not, can we:
- delete the orphaned saved searches in an update routine
- delete saved searches automatically when the smart group that uses them is deleted