-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Summary:
CiviCRM allows permissioned users to delete custom fields, including those in the Summary Fields group, as well as the Summary Fields custom field group itself.
If this happens, triggers that reference those deleted custom fields will cause fatal errors, which will cause related actions in CiviCRM to fail as well. E.g., cannot record a contribution if "Total Lifetime Contributions" Summary Field is a) enabled, and b) has had its custom field deleted by a site admin.
(Disclaimer: Naturally, nobody should be deleting these custom fields, but they can and sometimes do.)
Repro steps:
- Install Summary Fields.
- Enable any summary field (in this example I'll use Total Lifetime Contributions)
- Perform an action that will trigger a change on that summary field (e.g. create a new contribution), and observe that the summary field is behaving normally (e.g. is updated to reflect that new contribution)
- Manually delete the custom field (e.g. Summary Fields :: Total Lifetime Contributions.)
- Attempt to repeat the action in step 3 and observe a fatal error along the lines of "DB Error: No such field".
Failed attemps to workaround:
I was hopeful that this situation could be resolved by doing one or more of the following:
- Possibly: delete the entire Summary Fields custom field group if it still exists.
- Re-save the Summary Fields configuration settings form.
- Rebuild triggers.
- Completely uninstall and then re-enable Summary Fields
However, these steps don't resolve the problem, and indeed some of them (re-anabling Summary Fields after uninstalling it) are not possible because of fatal errors due to the missing custom fields/group.
Actual tedious workaround:
- As far as possible, take note of all existing Summary Fields configurations at [drupal.example.org]/civicrm/admin/setting/sumfields
- Uninstall the sumfields extension (and thus, jsumfields extension if it exists)
- Examine the file [sumfields-extension-dir]/settings/sumfields.setting.php and note the names of all settings defined therein (e.g. active_fields)
- Via SQL, delete all rows in civicrm_settings where name is one of those keys. (This steps is required because sumfields does not remove settings upon uninstall; then, upon enable, it references those settings, some of which may point to SQL tables/columns which have been deleted per the "repro steps" above.)
- Re-enable the sumfields extension (and jusumfields extension if it's needed).
- Visit the Summary Fields configuration page at [drupal.example.org]/civicrm/admin/setting/sumfields and re-configure everything according to the original settings that you took note of in step 2.
- Everything should be working fine now.
Suggestions for improvement in sumfields extension:
Some ways this extension might deal with the problem of admin users deleting Summary Fields custom fields/group might be:
- Find a way to use hooks to prevent deletion of Summary Fields custom fields/group.
- Find a way to remove the relevant triggers if someone deletes Summary Fields custom fields/group.
- Deal with the fatal error (mentioned above) upon re-enabling Summary Fields after uninstalling it when Summary Fields custom fields/group have been deleted.