From: deb.monish Date: Mon, 18 Jul 2016 13:19:10 +0000 (+0530) Subject: CRM-19094: cid=0 membership contribution form can overwrite data of an existing membe... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=75d83bd02587a57458d9fc480f6dca221c13319f;p=civicrm-core.git CRM-19094: cid=0 membership contribution form can overwrite data of an existing membership --- diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 70e42140df..ac894d059f 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -444,6 +444,12 @@ AND li.entity_id = {$entityId} if ($line['entity_table'] == 'civicrm_contribution') { $line['entity_id'] = $contributionDetails->id; } + // CRM-19094: entity_table is set to civicrm_membership then ensure + // the entityId is set to membership ID not contribution by default + elseif (!empty($line['entity_id']) && $line['entity_id'] == $contributionDetails->id) { + $membershipId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', 'contribution_id', $line['entity_id'], 'membership_id'); + $line['entity_id'] = $membershipId ? $membershipId : $line['entity_id']; + } } // if financial type is not set and if price field value is NOT NULL