CRM-17092 backport (do not merge) of fix to storing contribution_recur_id
authoreileenmcnaugton <eileen@fuzion.co.nz>
Wed, 26 Aug 2015 23:53:41 +0000 (11:53 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Thu, 27 Aug 2015 00:27:42 +0000 (12:27 +1200)
for renewals

Conflicts:
CRM/Member/Form/MembershipRenewal.php

CRM/Member/BAO/Membership.php
CRM/Member/Form.php
CRM/Member/Form/MembershipRenewal.php

index 2a319b87fde552123aab7600c4e7930e56298fb6..118d0de8f86028bed561cefb1a65cf2b04418110 100644 (file)
@@ -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'.
index 6bdd3c62e869d660243b162b2df95917a35cabb2..47b220cd5bbd726522cbf533c0d7706970f11d0c 100644 (file)
@@ -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;
   }
 
index ac40b1ab077054d08f4d1ed9ed72cbcb42e8e002..31f556e0efd929baaa1845f4f23054383cbec90e 100644 (file)
@@ -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);