From 74b91f33a1b400f8ce8f604dca272c77f8e06844 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 12 Nov 2015 08:36:58 -0800 Subject: [PATCH] CRM-17542424242 fix test processor being loaded when not applicable. The filter for test processors was including processors that were not included in the array --- CRM/Financial/BAO/PaymentProcessor.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 58a669ac5f..c8c31408ff 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -346,16 +346,15 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) { $mode = NULL; $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array(); - $processors = $liveProcessors = self::getAllPaymentProcessors('all'); + $processors = self::getAllPaymentProcessors('all'); if (in_array('TestMode', $capabilities)) { - if ($ids) { - foreach ($testProcessors as $testProcessor) { - if (!in_array($testProcessor['id'], $ids)) { - foreach ($liveProcessors as $liveProcessor) { - if ($liveProcessor['name'] == $testProcessor['name']) { - $ids[] = $testProcessor['id']; - } + $possibleLiveIDs = array_diff($ids, array_keys($testProcessors)); + foreach ($possibleLiveIDs as $possibleLiveID) { + if (isset($processors[$possibleLiveID]) && ($liveProcessorName = $processors[$possibleLiveID]['name']) != FALSE) { + foreach ($testProcessors as $index => $testProcessor) { + if ($testProcessor['name'] == $liveProcessorName) { + $ids[] = $testProcessor['id']; } } } @@ -364,7 +363,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } foreach ($processors as $index => $processor) { - if ($ids && !in_array($processor['id'], $ids)) { + if (is_array($ids) && !in_array($processor['id'], $ids)) { unset ($processors[$index]); continue; } -- 2.25.1