From 603fb32e53bab1631188043749e109952700014f Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Thu, 3 Oct 2019 11:23:52 +0100 Subject: [PATCH] Remove call to updateRecurMembership which is handled by Membership::create BAO --- CRM/Contribute/Form/Contribution/Confirm.php | 2 -- CRM/Member/BAO/Membership.php | 3 +++ tests/phpunit/api/v3/ContributionPageTest.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 3a7afb414a..d4654c0123 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1575,8 +1575,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } if (!empty($membershipContribution)) { - // update recurring id for membership record - CRM_Member_BAO_Membership::updateRecurMembership($membership, $membershipContribution); // Next line is probably redundant. Checks prevent it happening twice. $membershipPaymentParams = [ 'membership_id' => $membership->id, diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 6f9f222d9b..54ea9d0297 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1117,12 +1117,14 @@ AND civicrm_membership.is_test = %2"; } /** + * @deprecated This is not used anywhere and should be removed soon! * Function for updating a membership record's contribution_recur_id. * * @param CRM_Member_DAO_Membership $membership * @param \CRM_Contribute_BAO_Contribution|\CRM_Contribute_DAO_Contribution $contribution */ public static function updateRecurMembership(CRM_Member_DAO_Membership $membership, CRM_Contribute_BAO_Contribution $contribution) { + CRM_Core_Error::deprecatedFunctionWarning('Use the API instead'); if (empty($contribution->contribution_recur_id)) { return; @@ -1844,6 +1846,7 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND $membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID); $dates = []; $ids = []; + // CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType // is the same as the parent org of an existing membership of the contact $currentMembership = CRM_Member_BAO_Membership::getContactMembership($contactID, $membershipTypeID, diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 28a12cd926..631dc3a922 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -935,6 +935,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals($membership['contact_id'], $contribution['contact_id']); $this->assertEquals($expectedMembershipStatus, $membership['status_id']); $this->callAPISuccess('contribution_recur', 'getsingle', ['id' => $contribution['contribution_recur_id']]); + $this->assertEquals($contribution['contribution_recur_id'], $membership['contribution_recur_id']); $this->callAPISuccess('line_item', 'getsingle', ['contribution_id' => $contribution['id'], 'entity_id' => $membership['id']]); //renew it with processor setting completed - should extend membership -- 2.25.1