Remove call to updateRecurMembership which is handled by Membership::create BAO
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Thu, 3 Oct 2019 10:23:52 +0000 (11:23 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sun, 6 Oct 2019 16:58:35 +0000 (18:58 +0200)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Member/BAO/Membership.php
tests/phpunit/api/v3/ContributionPageTest.php

index 3a7afb414a3785d0d0baaf488b7e1a1eb8144127..d4654c012344cb4a0e48e16cfef5052b97dc7fd8 100644 (file)
@@ -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,
index 6f9f222d9be543d753d402871dd8ea84b026400b..54ea9d029781cf01ec629f2806aba31aee423c2f 100644 (file)
@@ -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,
index 28a12cd926a7ef0db94d813854b216f2b9372d0b..631dc3a92252bb1dca18330e8a1e0f34554be8ef 100644 (file)
@@ -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