From: Johan Vervloet Date: Tue, 10 Mar 2015 13:29:20 +0000 (+0100) Subject: CRM-16084 - a hack that fixes the issue. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9960c0ef88b8f8170e7bb09319e21cc0648a0a2d;p=civicrm-core.git CRM-16084 - a hack that fixes the issue. When you chain a relationship call to a contact call, and contact_id_a or contact_id_b is provided for the chained call, don't add the contact_id parameter. ---------------------------------------- * CRM-16084: API: when getting contact chaining relationships, the relationship direction is ignored https://issues.civicrm.org/jira/browse/CRM-16084 --- diff --git a/Civi/API/Subscriber/ChainSubscriber.php b/Civi/API/Subscriber/ChainSubscriber.php index e0a6209d45..a029faef6d 100644 --- a/Civi/API/Subscriber/ChainSubscriber.php +++ b/Civi/API/Subscriber/ChainSubscriber.php @@ -133,7 +133,24 @@ class ChainSubscriber implements EventSubscriberInterface { //set to the parent's id $subParams["entity_id"] = $parentAPIValues['id']; $subParams['entity_table'] = 'civicrm_' . $lowercase_entity; - $subParams[$lowercase_entity . "_id"] = $parentAPIValues['id']; + + $crm16084 = FALSE; + if ($subEntity == 'relationship' && $lowercase_entity == 'contact') { + // if a relationship call is chained to a contact call, we need + // to check whether contact_id_a or contact_id_b for the + // relationship is given. If so, don't add an extra subParam + // "contact_id" => parent_id. + // See CRM-16084. + foreach (array_keys($newparams) as $key) { + if (substr($key, 0, 11) == 'contact_id_') { + $crm16084 = TRUE; + break; + } + } + } + if (!$crm16084) { + $subParams[$lowercase_entity . "_id"] = $parentAPIValues['id']; + } } if ($entity != 'Contact' && \CRM_Utils_Array::value(strtolower($subEntity . "_id"), $parentAPIValues)) { //e.g. if event_id is in the values returned & subentity is event