Skip to content

Commit

Permalink
Merge pull request #13935 from eileenmcnaughton/recur_cancel_load
Browse files Browse the repository at this point in the history
dev/core#704 Fix loss of links for recurrings with no payment_processor_id
  • Loading branch information
mattwire authored Apr 4, 2019
2 parents e4d61a8 + 8701115 commit 45cf788
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
24 changes: 17 additions & 7 deletions CRM/Contribute/BAO/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,28 @@ public static function checkDuplicate($params, &$duplicates) {
* Get the payment processor (array) for a recurring processor.
*
* @param int $id
* @param string $mode
* - Test or NULL - all other variants are ignored.
*
* @return array|null
*/
public static function getPaymentProcessor($id, $mode = NULL) {
public static function getPaymentProcessor($id) {
$paymentProcessorID = self::getPaymentProcessorID($id);
if (!$paymentProcessorID) {
return NULL;
}
return CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID);
}

return CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode);

/**
* Get the processor object for the recurring contribution record.
*
* @param int $id
*
* @return CRM_Core_Payment|NULL
* Returns a processor object or NULL if the processor is disabled.
* Note this returns the 'Manual' processor object if no processor is attached
* (since it still makes sense to update / cancel
*/
public static function getPaymentProcessorObject($id) {
$processor = self::getPaymentProcessor($id);
return is_array($processor) ? $processor['object'] : NULL;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/Page/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static function &recurLinks($recurID = FALSE, $context = 'contribution')

if ($recurID) {
$links = self::$_links;
$paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj');
if (!is_object($paymentProcessorObj)) {
$paymentProcessorObj = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessorObject($recurID);
if (!$paymentProcessorObj) {
unset($links[CRM_Core_Action::DISABLE]);
unset($links[CRM_Core_Action::UPDATE]);
return $links;
Expand Down

0 comments on commit 45cf788

Please sign in to comment.