From 75d83bd02587a57458d9fc480f6dca221c13319f Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 18 Jul 2016 18:49:10 +0530 Subject: [PATCH] CRM-19094: cid=0 membership contribution form can overwrite data of an existing membership --- CRM/Price/BAO/LineItem.php | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.25.1