Prevent deletion of groups which are used as search parameters of Smart Groups
It seems that a group (static or Smart) being used a search parameter for a Smart Group can be deleted. Best case scenario is the Smart Group just has that many fewer contacts in it and we go on with life. We had an issue on a client site where there were so many contacts and so many groups, that rebuilding the Smart Group cache was causing a fatal DB error whether it (Updating Smart Group counts) was done manually or via the scheduled job. Proposed approach is to prevent deletion of groups that are dependencies for other groups. Example workflow:
- A user with permissions to delete groups chooses to delete a group by selecting the "Delete" option from the "More" link on the Manage Groups page located here: Navigation Menu > Contacts > Manage Groups (this is the only place a user can delete a group, I believe)
- The system (CiviCRM) does a check in the background to determine if the group being deleted is used as a search parameter in any active/non-deleted Smart Groups
- If the group being deleted is determined to be "in use" by a Smart Group(s), don't allow the group to be deleted. Instead…
- Show a message in the "Confirm Group Delete" notification that the group cannot be deleted as it's being used by a Smart Group(s). List the name of the Smart Group(s), preferably with the name(s) linked to that/those group(s)
I am inquiring with our client if they are willing to put funds (and how much) into fixing this. I have confirmed on demo master that one can delete a group that is a dependency for another group, though there were no ill effects. My assumption / theory is there just aren't enough contacts or groups for the rebuilding of Smart Group counts to fail.