Skip to content

Commit

Permalink
CRM-20345 - Don't be tripped up by deleted contacts or inactive relat…
Browse files Browse the repository at this point in the history
…ionships
  • Loading branch information
colemanw committed Mar 30, 2017
1 parent 4c6cc36 commit 7a51786
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CRM/Case/BAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ public static function getRelatedContacts($caseID, $includeDetails = TRUE) {
LEFT JOIN civicrm_email ce
ON ce.contact_id = cc.id
AND ce.is_primary= 1
WHERE cr.case_id = %1';
WHERE cr.case_id = %1 AND cr.is_active AND cc.is_deleted <> 1';

$params = array(1 => array($caseID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
Expand Down
2 changes: 1 addition & 1 deletion api/v3/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function civicrm_api3_case_get($params, $sql = NULL) {
// Add necessary joins to the first case client
if ($contactSort) {
$sql->join('ccc', 'LEFT JOIN (SELECT * FROM civicrm_case_contact WHERE id IN (SELECT MIN(id) FROM civicrm_case_contact GROUP BY case_id)) AS ccc ON ccc.case_id = a.id');
$sql->join('case_contact', 'LEFT JOIN civicrm_contact AS case_contact ON ccc.contact_id = case_contact.id');
$sql->join('case_contact', 'LEFT JOIN civicrm_contact AS case_contact ON ccc.contact_id = case_contact.id AND case_contact.is_deleted <> 1');
}
}

Expand Down

0 comments on commit 7a51786

Please sign in to comment.