CRM-19094: cid=0 membership contribution form can overwrite data of an existing membe...
authordeb.monish <monish.deb@webaccessglobal.com>
Mon, 18 Jul 2016 13:19:10 +0000 (18:49 +0530)
committerdeb.monish <monish.deb@webaccessglobal.com>
Mon, 18 Jul 2016 14:39:54 +0000 (20:09 +0530)
CRM/Price/BAO/LineItem.php

index 70e42140df1f8c5d07bcb1f8284b8ed15ab6c8e0..ac894d059fa23d2efbda2f45533ac20ad8d73ff5 100644 (file)
@@ -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