Skip to content

Commit

Permalink
CRM-20935 Remove related profile links when event deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
JKingsnorth committed Jul 21, 2017
1 parent 6005042 commit 1f46cfe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ public static function del($id) {
CRM_Core_DAO::executeQuery($query);
}

// Clean up references to profiles used by the event (CRM-20935)
$ufJoinParams = array(
'module' => 'CiviEvent',
'entity_table' => 'civicrm_event',
'entity_id' => $id,
);
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$ufJoinParams = array(
'module' => 'CiviEvent_Additional',
'entity_table' => 'civicrm_event',
'entity_id' => $id,
);
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);

// price set cleanup, CRM-5527
CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $id);

Expand Down
7 changes: 7 additions & 0 deletions CRM/Upgrade/Incremental/sql/4.7.23.mysql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ ON price_field.price_field_id = cpf.id
LEFT JOIN civicrm_price_set ps ON ps.id = cpf.price_set_id
SET cpf.is_active = 1
WHERE ps.is_quick_config = 1 AND cpf.is_active = 0;

-- CRM-20935 Clean up orphaned profile links for deleted events
DELETE civicrm_uf_join
FROM civicrm_uf_join
LEFT JOIN civicrm_event e on civicrm_uf_join.entity_id = e.id
WHERE (civicrm_uf_join.module = 'CiviEvent' OR civicrm_uf_join.module = 'CiviEvent_Additional')
AND e.id IS NULL;

0 comments on commit 1f46cfe

Please sign in to comment.