From: Brian Shaughnessy Date: Tue, 19 Mar 2013 13:50:35 +0000 (-0400) Subject: CRM-12153 work around unique index constraint when merging tags X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c2105be3e1c409993da36d29feb7f0c63538abdd;p=civicrm-core.git CRM-12153 work around unique index constraint when merging tags --- diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index 9602f50845..28842861d7 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -361,13 +361,15 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { // get all merge queries together $sqls = array( // 1. update entity tag entries - "UPDATE civicrm_entity_tag SET tag_id = %1 WHERE tag_id = %2", + "UPDATE IGNORE civicrm_entity_tag SET tag_id = %1 WHERE tag_id = %2", // 2. update used_for info for tag B "UPDATE civicrm_tag SET used_for = '{$usedFor}' WHERE id = %1", // 3. remove tag A, if tag A is getting merged into B "DELETE FROM civicrm_tag WHERE id = %2", // 4. remove duplicate entity tag records "DELETE et2.* from civicrm_entity_tag et1 INNER JOIN civicrm_entity_tag et2 ON et1.entity_table = et2.entity_table AND et1.entity_id = et2.entity_id AND et1.tag_id = et2.tag_id WHERE et1.id < et2.id", + // 5. remove orphaned entity_tags + "DELETE FROM civicrm_entity_tag WHERE tag_id = %2", ); $tables = array('civicrm_entity_tag', 'civicrm_tag');