compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

MAE-486: Fix payment plan after CiviCRM 5.35 #362

Closed ahed-compucorp closed 3 years ago

ahed-compucorp commented 3 years ago

Overview

After updating to CiviCRM 5.35 we cannot create payment plan memberships.

Before

You cannot create a payment plan memberships on CiviCRM 5.35.

After

You can create a payment plan memberships on CiviCRM 5.35.

Technical Details

A small change in CiviCRM internal caused this bug.

In CiviCRM 5.28, BAO/Membership.php#L334 will create the contribution and will add the membership_id to params array.

// Record contribution for this membership and create a MembershipPayment
if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) {
  $memInfo = array_merge($params, ['membership_id' => $membership->id]);
  $params['contribution'] = self::recordMembershipContribution($memInfo);
}

In CiviCRM 5.35, Form/Membership.php#L1451 will create the contribution but will not add the membership_id to params array.

  if (!empty($formValues['record_contribution'])) {
    CRM_Member_BAO_Membership::recordMembershipContribution($params);
  }

Because of that, this PR :