CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Loss of custom data fields when contact is deleted
Pages: [1]

Author Topic: Loss of custom data fields when contact is deleted  (Read 1585 times)

Will Brownsberger

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 2
Loss of custom data fields when contact is deleted
November 29, 2009, 06:48:49 am
Warning:  If you delete the contact who created a custom data group, you can lose access to the custom data.

To protect yourself against this risk, upon creating custom data groups, visit the table civicrm_custom_group through phpmyAdmin and set the value of created-id to null for your new group.

It seems that the field created-id on the table civicrm_custom_group is set to the value of the logged in contact creating the custom_group.

This is logical enough, but if that contact is deleted, civicrm_custom_group records are deleted and this cascades to delete the associated fields in civicrm_custom_field.

The actual custom data tables are not deleted, but the recovery would require some careful data surgery to recreate the entries in custom_group and custom_field to point to the data so that civicrm can see it if a good backup were not available.

Instead of deleting the civicrm_custom_group record, the field created-id should be set to a null value on deletion of the contact.  I have reported this as a bug issue.

Note that the merge duplicate function also mishandles this case.


Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Loss of custom data fields when contact is deleted
November 29, 2009, 08:15:59 pm
Will - thx for surfacing this. Using onDelete SET NULL seems like the right thing to do here - just checking with others on the team to see if there was some "good" reason we used CASCADE here (i doubt it).
Protect your investment in CiviCRM by  becoming a Member!

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Loss of custom data fields when contact is deleted
November 30, 2009, 12:56:19 am
For tracking purpose: http://issues.civicrm.org/jira/browse/CRM-5451

Also, issue filed to improve behavior for merge (scheduled for 3.2): http://issues.civicrm.org/jira/browse/CRM-5455

Kurund
« Last Edit: November 30, 2009, 10:00:09 am by Dave Greenberg »
Found this reply helpful? Support CiviCRM

Will Brownsberger

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 2
Re: Loss of custom data fields when contact is deleted
November 30, 2009, 10:08:22 am
Thanks for the quick response.  I put a note on this in the Wiki at http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=22905639

I defer to you as to whether and how long it belongs there.

Best regards,

Will B.

delita

  • Guest
Re: Loss of custom data fields when contact is deleted
January 23, 2010, 06:49:52 pm
I just got burned by this same behavior.  Deleted an Individual contact I had used for configuring a client site and suddenly my Custom Data Groups are all gone - that's incredibly frustrating and there was no warning - *sigh* - guess I'll recreate and then take Will's advice and set created-id to null on the recreated data groups.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Loss of custom data fields when contact is deleted
January 24, 2010, 07:59:10 am

this was fixed in 3.0.3 (released over 6 weeks ago). It does help to be on the latest stable version to ensure you get both critical and non-critical bug fixes

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Loss of custom data fields when contact is deleted

This forum was archived on 2017-11-26.