From: eileenmcnaugton Date: Wed, 26 Aug 2015 23:53:41 +0000 (+1200) Subject: CRM-17092 backport (do not merge) of fix to storing contribution_recur_id X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9c4b1b59fdb365507b776a1f6a8998f6edfc7411;p=civicrm-core.git CRM-17092 backport (do not merge) of fix to storing contribution_recur_id for renewals Conflicts: CRM/Member/Form/MembershipRenewal.php --- diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 2a319b87fd..118d0de8f8 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -2495,7 +2495,7 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND } CRM_Member_BAO_MembershipLog::add($logParams, CRM_Core_DAO::$_nullArray); - if (!empty($contributionRecurID)) { + if ($contributionRecurID) { CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $membership->id, 'contribution_recur_id', $contributionRecurID ); @@ -2625,12 +2625,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 6bdd3c62e8..47b220cd5b 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -257,15 +257,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 ac40b1ab07..31f556e0ef 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -615,9 +615,10 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; if (!empty($paymentParams['auto_renew'])) { $contributionRecurParams = $this->processRecurringContribution($paymentParams); + $this->_params['contributionRecurID'] = $contributionRecurParams['contributionRecurID']; $paymentParams = array_merge($paymentParams, $contributionRecurParams); } - $result = &$payment->doDirectPayment($paymentParams); + $result = $payment->doDirectPayment($paymentParams); if (is_a($result, 'CRM_Core_Error')) { CRM_Core_Error::displaySessionError($result);