From: eileenmcnaugton Date: Wed, 26 Aug 2015 23:53:41 +0000 (+1200) Subject: CRM-17092 fix for recurring contribution id not set on membership X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1406526683059031969977ca161629964a5e8161;p=civicrm-core.git CRM-17092 fix for recurring contribution id not set on membership --- diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index c6f8545be5..8fd061802b 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1853,7 +1853,7 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND } CRM_Member_BAO_MembershipLog::add($logParams); - if (!empty($contributionRecurID)) { + if ($contributionRecurID) { CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $membership->id, 'contribution_recur_id', $contributionRecurID ); @@ -1983,12 +1983,14 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND if (!empty($membershipSource)) { $memParams['source'] = $membershipSource; } - $memParams['contribution_recur_id'] = $contributionRecurID; - $memParams['is_test'] = $is_test; $memParams['is_pay_later'] = $isPayLater; } - + // Putting this in an IF is precautionary as it seems likely that it would be ignored if empty, but + // perhaps shouldn't be? + if ($contributionRecurID) { + $memParams['contribution_recur_id'] = $contributionRecurID; + } //CRM-4555 //if we decided status here and want to skip status //calculation in create( ); then need to pass 'skipStatusCal'. diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 8d7a2e1f33..ca06acb5c5 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -348,15 +348,14 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { 'return' => $mapping, )); + $returnParams = array('is_recur' => TRUE); foreach ($mapping as $recurringFieldName => $membershipTypeFieldName) { $contributionRecurParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName]; + $returnParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName]; } $contributionRecur = civicrm_api3('ContributionRecur', 'create', $contributionRecurParams); - $returnParams = array( - 'contributionRecurID' => $contributionRecur['id'], - 'is_recur' => TRUE, - ); + $returnParams['contributionRecurID'] = $contributionRecur['id']; return $returnParams; } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index e7a0f00af2..b9020c78c2 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -506,7 +506,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { if (empty($this->_params['financial_type_id'])) { $this->_params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id'); } - + $contributionRecurID = NULL; $this->assign('membershipID', $this->_id); $this->assign('contactID', $this->_contactID); $this->assign('module', 'Membership'); @@ -543,6 +543,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { if (!empty($this->_params['auto_renew'])) { $contributionRecurParams = $this->processRecurringContribution($paymentParams); + $contributionRecurID = $contributionRecurParams['contributionRecurID']; $paymentParams = array_merge($paymentParams, $contributionRecurParams); }