Answers.Body: <p>As well as Andrew's answer, which involves directly deleting the Location Type, I believe there is a route that this can be done inadvertently when editing a single contact record in order to delete a single address record. This came up on this <a href="https://issues.civicrm.org/jira/browse/CRM-17273" rel="nofollow">JIRA ticket</a>.</p>
  
  <p>In the scenario we investigated, it seems that the user was editing a single record, and in order to edit a single address entry they accidentally / inadvertently clicked on the 'spanner' icon to the right which opens up the Location Type page, and this gives access to the Delete button which it is concievable the person might click on thinking they are deleting the single Address, rather than the Location Type.</p>
  
  <p>They do then get the big warning noted in Andrew's answer which we are suggesting could be improved in the JIRA ticket.</p>
  
  <p>Note that the user requires 'administer CiviCRM' permission to get that link to edit location types.</p>
  
  <p>It was possible to restore the data from the log_tables in this case.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-07T18:42:02.337Z
Answers.LastActivityDate: 2015-10-07T18:42:02.337Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>I've seen this happen three times now - someone intends to delete an email/address/phone number, ends up attempting to delete the entire location type.  I decided this was too dangerous, so as of CiviCRM 4.6.12 and 4.7, you can no longer edit location type when inline editing phone/email/address/IM.  See <a href="https://issues.civicrm.org/jira/browse/CRM-17273" rel="nofollow">https://issues.civicrm.org/jira/browse/CRM-17273</a> for details.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-25T23:31:52.093Z
Answers.LastActivityDate: 2016-01-25T23:31:52.093Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>I'm curious about your claim that you lost all that data. Is it possible it's there but just not showing up where you expect? The location type is just a way of classifying the data that lives in it's own tables.</p>
  
  <p>Unless there's another trigger that clears all the data, it's possible that the data is still there and could be recovered by adding a new location and then using sql to update the id of that new location so it's connected to all the existing actual data. Your error suggests that because of the foreign key dependency the type wasn't even deleted, but maybe just the label.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-07T16:39:08.257Z
Answers.Text: I'm pretty sure the data is gone, both from the debug message, but also because when you try to delete a location type, this warning pops up: "WARNING: Deleting this option will result in the loss of all location type records which use the option. This may mean the loss of a substantial amount of data, and the action cannot be undone. Do you want to continue?"  Of course - this message may have been added in response to this person's problem, which happened back in June.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-07T15:02:26.137Z
Answers.LastActivityDate: 2015-10-07T15:02:26.137Z
Answers.UserDisplayName: Alan Dixon
Answers.Body: <p>This is a result of someone going in CiviCRM and deleting the Home location type, either through <strong>Administer > Customize Data and Screens > Dropdown Options > Location Types</strong> or clicking the wrench next to the dropdown of location types on some other form.</p>
  
  <p>It's obviously not a good idea to do that if you have a lot of email addresses, phone numbers, and postal addresses with that location type; doing so will actually give you the message:</p>
  
  <blockquote>
    <p>WARNING: Deleting this option will result in the loss of all location type records which use the option. This may mean the loss of a substantial amount of data, and the action cannot be undone. Do you want to continue? </p>
  </blockquote>
  
  <p>I hope/assume that nobody did that on purpose, but you might double-check with everyone with that permission.</p>
  
  <p>If you can't track down who did it, you should assume someone has compromised your system and has admin permissions (or potentially full shell and/or MySQL access such that they could create a user).  At the very least, each user should change passwords, and you should review all user accounts in WordPress.  To be truly safe, you might reset/reinstall everything in your hosting environement, replace all your WordPress, CiviCRM, and other plugins' code with freshly-downloaded copies, manually review any other files one-by-one, and check your database for anything fishy.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T17:33:35.187Z
Answers.Text: Thanks Andrew! We're tracking down anyone internally that might have done this and changing all admin passwords. I'll work with our developer on the next level of security should no one fess up:) Have a great day!
Answers.UserDisplayName: BraddC
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T09:58:12.817Z
Answers.Text: If they have logging enabled, it would be easy to find who to blame^H^H^H^H^Hpolitely educate on the virtues of looking before you leap. SELECT * FROM log_civicrm_location_type WHERE log_action = 'Delete'
Answers.UserDisplayName: DaveFF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-08T17:11:04.023Z
Answers.Text: @DaveFF if you don't have logging enabled, how to you find out how the data has been deleted?
Answers.UserDisplayName: Kboy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-08T17:29:25.960Z
Answers.Text: @Kennedy don't know I'm afraid! There is also a table called civicrm_log but I've never had cause to look in there. Or the debug log files, but they don't cover every change in detail the way having full logging enabled does.
Answers.UserDisplayName: DaveFF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-08T18:22:28.380Z
Answers.Text: For an advanced forensic investigation, you could figure out the url they had to POST to to do this, and then look for the corresponding entry in your web server log file, and then try and figure out who it was from the IP.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T14:43:50.507Z
Answers.LastActivityDate: 2015-06-17T14:43:50.507Z
Answers.UserDisplayName: Andie Hunt
Body: <p>So we lost 2/3 of our email and addresses on 6/15 around 1pm. Everything else seemed fine. I was able to get the civi log that pointed to a deletion command (DELETE FROM civicrm_location_type) around the same time. We have no idea how this happened. Thankfully we were able to make a new database from a backup file and not much damage was done.</p>
  
  <p>Does anyone know what could have caused this and how we could prevent it in the future? Thanks!</p>
  
  <p>Here's the log:</p>
  
  <pre><code>Jun 15 13:11:01  [info] $Fatal Error Details = Array
  (
      [callback] =&gt; Array
          (
              [0] =&gt; CRM_Core_Error
              [1] =&gt; handle
          )
  
      [code] =&gt; -3
      [message] =&gt; DB Error: constraint violation
      [mode] =&gt; 16
      [debug_info] =&gt; DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`gbapgh_civicrm`.`civicrm_mapping_field`, CONSTRAINT `FK_civicrm_mapping_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`))]
      [type] =&gt; DB_Error
      [user_info] =&gt; DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`gbapgh_civicrm`.`civicrm_mapping_field`, CONSTRAINT `FK_civicrm_mapping_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`))]
      [to_string] =&gt; [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`gbapgh_civicrm`.`civicrm_mapping_field`, CONSTRAINT `FK_civicrm_mapping_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`))]"]
  )
  
  
  Jun 15 13:11:01  [info] $backTrace = #0 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(239): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
  #2 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
  #3 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB.php(975): PEAR_Error-&gt;PEAR_Error("DB Error: constraint violation", -3, 16, (Array:2), "DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [...")
  #4 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(564): DB_Error-&gt;DB_Error(-3, 16, (Array:2), "DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [...")
  #5 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR-&gt;raiseError(NULL, -3, NULL, NULL, "DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [...", "DB_Error", TRUE)
  #6 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(899): DB_common-&gt;raiseError(-3, NULL, NULL, NULL, "1451 ** Cannot delete or update a parent row: a foreign key constraint fails ...")
  #7 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(328): DB_mysql-&gt;mysqlRaiseError()
  #8 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysql-&gt;simpleQuery("DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 ) ")
  #9 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2442): DB_common-&gt;query("DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 ) ")
  #10 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1456): DB_DataObject-&gt;_query("DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 ) ")
  #11 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/LocationType.php(179): DB_DataObject-&gt;delete()
  #12 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/LocationType.php(96): CRM_Core_BAO_LocationType::del("1")
  #13 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(328): CRM_Admin_Form_LocationType-&gt;postProcess()
  #14 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(162): CRM_Core_Form-&gt;mainProcess()
  #15 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(60): CRM_Core_StateMachine-&gt;perform(Object(CRM_Admin_Form_LocationType), "next", "Next")
  #16 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next-&gt;perform(Object(CRM_Admin_Form_LocationType), "next")
  #17 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Admin_Form_LocationType), "next")
  #18 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(356): HTML_QuickForm_Page-&gt;handle("next")
  #19 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(395): CRM_Core_Controller-&gt;run()
  #20 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(178): CRM_Core_Page_Basic-&gt;edit(8, "1")
  #21 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(331): CRM_Core_Page_Basic-&gt;run((Array:3), NULL)
  #22 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(75): CRM_Core_Invoke::runItem((Array:13))
  #23 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
  #24 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm.php(506): CRM_Core_Invoke::invoke((Array:3))
  #25 [internal function](): CiviCRM_For_WordPress-&gt;invoke("")
  #26 /usr/home/gbapgh/public_html/go-gba/wp-includes/plugin.php(505): call_user_func_array((Array:2), (Array:1))
  #27 /usr/home/gbapgh/public_html/go-gba/wp-admin/admin.php(212): do_action("toplevel_page_CiviCRM")
  #28 {main}
  
  
  Jun 15 13:41:30  [info] r_authresponse X07
  
  Jun 15 13:41:30  [info] r_code 03924D1557233524:YYYM:
  
  Jun 15 13:41:30  [info] r_tdate 1434390089
  
  Jun 15 13:41:30  [info] r_avs YYYM
  
  Jun 15 13:41:30  [info] r_ordernum A7DEDC06-557F0E49-608-E0474
  
  Jun 15 13:41:30  [info] r_error 
  
  Jun 15 13:41:30  [info] csp FDMS
  
  Jun 15 13:41:30  [info] r_message APPROVED
  
  Jun 15 13:41:30  [info] r_ref 1557233524
  
  Jun 15 13:41:30  [info] r_time Mon Jun 15 13:41:30 2015
  
  Jun 15 13:44:08  [info] $Fatal Error Details = Array
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-17T16:45:28.740Z
Comments.Text: In the future, please edit your post rather than creating an entirely new question. Previous question: *[Email and Addresses Missing](http://civicrm.stackexchange.com/questions/3245)*
Comments.UserDisplayName: choster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-08T11:10:26.300Z
Comments.Text: We are also seeing email addresses disappearing. From the log it is my id which did a bulk delete but I don't remember doing it. Also my Home record is in place and never deleted or changed,
Comments.UserDisplayName: user469
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-08T11:30:48.257Z
Comments.Text: I had this same issue in March 2015 and i restored data from backup, see my post here https://forum.civicrm.org/index.php?topic=35945.msg152720#msg152720
Comments.UserDisplayName: Kboy
Tags: <database><security>
Title: Why did we lose contact data after deleting the default location type "Home"?
ThreadText: # Why did we lose contact data after deleting the default location type "Home"?
  
  (Asked by: username_0 on 2015-06-17)
  
  So we lost 2/3 of our email and addresses on 6/15 around 1pm. Everything else seemed fine. I was able to get the civi log that pointed to a deletion command (DELETE FROM civicrm_location_type) around the same time. We have no idea how this happened. Thankfully we were able to make a new database from a backup file and not much damage was done.
  Does anyone know what could have caused this and how we could prevent it in the future? Thanks!
  Here's the log:
  Jun 15 13:11:01  [info] $Fatal Error Details = Array
  (
      [callback] => Array
          (
              [0] => CRM_Core_Error
              [1] => handle
          )
  
      [code] => -3
      [message] => DB Error: constraint violation
      [mode] => 16
      [debug_info] => DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`gbapgh_civicrm`.`civicrm_mapping_field`, CONSTRAINT `FK_civicrm_mapping_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`))]
      [type] => DB_Error
      [user_info] => DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`gbapgh_civicrm`.`civicrm_mapping_field`, CONSTRAINT `FK_civicrm_mapping_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`))]
      [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`gbapgh_civicrm`.`civicrm_mapping_field`, CONSTRAINT `FK_civicrm_mapping_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`))]"]
  )
  
  
  Jun 15 13:11:01  [info] $backTrace = #0 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(239): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
  #2 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
  #3 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB.php(975): PEAR_Error->PEAR_Error("DB Error: constraint violation", -3, 16, (Array:2), "DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [...")
  #4 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-3, 16, (Array:2), "DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [...")
  #5 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -3, NULL, NULL, "DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 )  [...", "DB_Error", TRUE)
  #6 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(899): DB_common->raiseError(-3, NULL, NULL, NULL, "1451 ** Cannot delete or update a parent row: a foreign key constraint fails ...")
  #7 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()
  #8 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 ) ")
  #9 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2442): DB_common->query("DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 ) ")
  #10 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1456): DB_DataObject->_query("DELETE FROM civicrm_location_type  WHERE (  civicrm_location_type.id = 1 ) ")
  #11 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/LocationType.php(179): DB_DataObject->delete()
  #12 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/LocationType.php(96): CRM_Core_BAO_LocationType::del("1")
  #13 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(328): CRM_Admin_Form_LocationType->postProcess()
  #14 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(162): CRM_Core_Form->mainProcess()
  #15 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(60): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_LocationType), "next", "Next")
  #16 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_LocationType), "next")
  #17 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_LocationType), "next")
  #18 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(356): HTML_QuickForm_Page->handle("next")
  #19 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(395): CRM_Core_Controller->run()
  #20 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(178): CRM_Core_Page_Basic->edit(8, "1")
  #21 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(331): CRM_Core_Page_Basic->run((Array:3), NULL)
  #22 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(75): CRM_Core_Invoke::runItem((Array:13))
  #23 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
  #24 /usr/home/gbapgh/public_html/go-gba/wp-content/plugins/civicrm/civicrm.php(506): CRM_Core_Invoke::invoke((Array:3))
  #25 [internal function](): CiviCRM_For_WordPress->invoke("")
  #26 /usr/home/gbapgh/public_html/go-gba/wp-includes/plugin.php(505): call_user_func_array((Array:2), (Array:1))
  #27 /usr/home/gbapgh/public_html/go-gba/wp-admin/admin.php(212): do_action("toplevel_page_CiviCRM")
  #28 {main}
  
  
  Jun 15 13:41:30  [info] r_authresponse X07
  
  Jun 15 13:41:30  [info] r_code 03924D1557233524:YYYM:
  
  Jun 15 13:41:30  [info] r_tdate 1434390089
  
  Jun 15 13:41:30  [info] r_avs YYYM
  
  Jun 15 13:41:30  [info] r_ordernum A7DEDC06-557F0E49-608-E0474
  
  Jun 15 13:41:30  [info] r_error 
  
  Jun 15 13:41:30  [info] csp FDMS
  
  Jun 15 13:41:30  [info] r_message APPROVED
  
  Jun 15 13:41:30  [info] r_ref 1557233524
  
  Jun 15 13:41:30  [info] r_time Mon Jun 15 13:41:30 2015
  
  Jun 15 13:44:08  [info] $Fatal Error Details = Array
  
  **Tags:** database, security
  
  > **Comments:**
  > **username_1**: In the future, please edit your post rather than creating an entirely new question. Previous question: *[Email and Addresses Missing](http://civicrm.stackexchange.com/questions/3245)*  
  > **username_2**: We are also seeing email addresses disappearing. From the log it is my id which did a bulk delete but I don't remember doing it. Also my Home record is in place and never deleted or changed,  
  > **username_3**: I had this same issue in March 2015 and i restored data from backup, see my post here https://forum.civicrm.org/index.php?topic=35945.msg152720#msg152720  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_7 on 2015-06-17. Score: 5 | Accepted answer
  
  This is a result of someone going in CiviCRM and deleting the Home location type, either through **Administer > Customize Data and Screens > Dropdown Options > Location Types** or clicking the wrench next to the dropdown of location types on some other form.
  
  It's obviously not a good idea to do that if you have a lot of email addresses, phone numbers, and postal addresses with that location type; doing so will actually give you the message:
  
  > WARNING: Deleting this option will result in the loss of all location type records which use the option. This may mean the loss of a substantial amount of data, and the action cannot be undone. Do you want to continue?
  
  I hope/assume that nobody did that on purpose, but you might double-check with everyone with that permission.
  
  If you can't track down who did it, you should assume someone has compromised your system and has admin permissions (or potentially full shell and/or MySQL access such that they could create a user). At the very least, each user should change passwords, and you should review all user accounts in WordPress. To be truly safe, you might reset/reinstall everything in your hosting environement, replace all your WordPress, CiviCRM, and other plugins' code with freshly-downloaded copies, manually review any other files one-by-one, and check your database for anything fishy.
  
  > **Comments:**
  > **username_0**: Thanks Andrew! We're tracking down anyone internally that might have done this and changing all admin passwords. I'll work with our developer on the next level of security should no one fess up:) Have a great day!  
  > **username_8**: If they have logging enabled, it would be easy to find who to blame^H^H^H^H^Hpolitely educate on the virtues of looking before you leap. SELECT * FROM log_civicrm_location_type WHERE log_action = 'Delete'  
  > **username_3**: @username_8 if you don't have logging enabled, how to you find out how the data has been deleted?  
  > **username_8**: @Kennedy don't know I'm afraid! There is also a table called civicrm_log but I've never had cause to look in there. Or the debug log files, but they don't cover every change in detail the way having full logging enabled does.  
  > **username_6**: For an advanced forensic investigation, you could figure out the url they had to POST to to do this, and then look for the corresponding entry in your web server log file, and then try and figure out who it was from the IP.  
  
  ---
  
  ### Answer by username_4 on 2015-10-07. Score: 3
  
  As well as Andrew's answer, which involves directly deleting the Location Type, I believe there is a route that this can be done inadvertently when editing a single contact record in order to delete a single address record. This came up on this [JIRA ticket](https://issues.civicrm.org/jira/browse/CRM-17273).
  
  In the scenario we investigated, it seems that the user was editing a single record, and in order to edit a single address entry they accidentally / inadvertently clicked on the 'spanner' icon to the right which opens up the Location Type page, and this gives access to the Delete button which it is concievable the person might click on thinking they are deleting the single Address, rather than the Location Type.
  
  They do then get the big warning noted in Andrew's answer which we are suggesting could be improved in the JIRA ticket.
  
  Note that the user requires 'administer CiviCRM' permission to get that link to edit location types.
  
  It was possible to restore the data from the log\_tables in this case.
  
  
  ---
  
  ### Answer by username_5 on 2016-01-25. Score: 3
  
  I've seen this happen three times now - someone intends to delete an email/address/phone number, ends up attempting to delete the entire location type. I decided this was too dangerous, so as of CiviCRM 4.6.12 and 4.7, you can no longer edit location type when inline editing phone/email/address/IM. See <https://issues.civicrm.org/jira/browse/CRM-17273> for details.
  
  
  ---
  
  ### Answer by username_6 on 2015-10-07. Score: 0
  
  I'm curious about your claim that you lost all that data. Is it possible it's there but just not showing up where you expect? The location type is just a way of classifying the data that lives in it's own tables.
  
  Unless there's another trigger that clears all the data, it's possible that the data is still there and could be recovered by adding a new location and then using sql to update the id of that new location so it's connected to all the existing actual data. Your error suggests that because of the foreign key dependency the type wasn't even deleted, but maybe just the label.
  
  > **Comments:**
  > **username_5**: I'm pretty sure the data is gone, both from the debug message, but also because when you try to delete a location type, this warning pops up: "WARNING: Deleting this option will result in the loss of all location type records which use the option. This may mean the loss of a substantial amount of data, and the action cannot be undone. Do you want to continue?"  Of course - this message may have been added in response to this person's problem, which happened back in June.  
  
  ---
  
  