diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 28881af2f12e..fb159502685f 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -5387,11 +5387,14 @@ protected static function isPaymentInstrumentChange(&$params, $pendingStatuses) */ protected static function updateMembershipBasedOnCompletionOfContribution($contribution, $primaryContributionID, $changeDate) { // Load memberships from contribution info. There may be multiple memberships (or none) + $membershipFields = array('id', 'contact_id', 'is_test', 'membership_type_id', 'contribution_recur_id', 'status_id.is_current_member', + 'start_date', 'join_date', 'end_date', 'status_id'); $memberships = array(); if (!empty($contribution->contribution_recur_id)) { // Load memberships associated with recurring contribution $membershipResult = civicrm_api3('Membership', 'get', array( 'contribution_recur_id' => $contribution->contribution_recur_id, + 'return' => $membershipFields, )); } elseif (!empty($primaryContributionID)) { @@ -5405,6 +5408,7 @@ protected static function updateMembershipBasedOnCompletionOfContribution($contr } $membershipResult = civicrm_api3('Membership', 'get', array( 'id' => array('IN' => $membershipIDs), + 'return' => $membershipFields, )); } } @@ -5412,6 +5416,7 @@ protected static function updateMembershipBasedOnCompletionOfContribution($contr $memberships = $membershipResult['values']; } + // Loop through all found memberships and update status/renew foreach ($memberships as $membershipId => $membership) { if ($membership) { if ((!empty($contribution->contribution_recur_id)) @@ -5433,18 +5438,14 @@ protected static function updateMembershipBasedOnCompletionOfContribution($contr ); // Does the contact have a "current" membership (ie. not expired/pending etc). - $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'], - $membershipParams['membership_type_id'], - $membershipParams['is_test'], - $membershipParams['id'] - ); - if ($currentMembership) { + if (!empty($membership['status_id.is_current_member'])) { /* * Fixed FOR CRM-4433 * In BAO/Membership.php(renewMembership function), we skip the extend membership date and status * when Contribution mode is notify and membership is for renewal ) + * FIXME: Is this still required? */ - CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeDate); + CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($membership, $changeDate); } // Tell the Membership BAO to calculate membership status.