Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-1150

civicrm_entity_tag entries not deleted when contact deleted

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Labels:
      None

      Description

      I created a new Organization, applied tags to it and verified the corresponding db entries:

      mysql> select id, contact_type, display_name from civicrm_contact where id = 15393;
      -------------------------------

      id contact_type display_name

      -------------------------------

      15393 Organization Test Org 6

      -------------------------------
      1 row in set (0.00 sec)

      mysql> select * from civicrm_entity_tag where entity_id = 15393;
      -------------------------------------+

      id entity_table entity_id tag_id

      -------------------------------------+

      18432 civicrm_contact 15393 1
      18433 civicrm_contact 15393 7

      -------------------------------------+
      2 rows in set (0.05 sec)

      I then deleted the Organization from the UI and checked th db tables once more:

      mysql> select id, contact_type, display_name from civicrm_contact where id = 15393;
      Empty set (0.00 sec)

      mysql> select * from civicrm_entity_tag where entity_id = 15393;
      -------------------------------------+

      id entity_table entity_id tag_id

      -------------------------------------+

      18432 civicrm_contact 15393 1
      18433 civicrm_contact 15393 7

      -------------------------------------+
      2 rows in set (0.04 sec)

      I discovered this bug when, at the end an import, I was informed that some of the contacts could not be tagged because they already bore the relevant tag, even though I had deleted all contacts before the import. I checked the civicrm_entity_tag table and found:

      mysql> select count(distinct entity_id) from civicrm_entity_tag where entity_table = 'civicrm_contact';
      ---------------------------

      count(distinct entity_id)

      ---------------------------

      14753

      ---------------------------
      1 row in set (0.53 sec)

      mysql> select count from civicrm_contact;
      ----------

      count

      ----------

      3490

      ----------
      1 row in set (0.03 sec)

      So this problem had apparently been going on for a while.

        Attachments

          Activity

            People

            • Assignee:
              swati Swati Vaidya
              Reporter:
              davej Dave Jenkins
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: