Skip to content

Commit

Permalink
Use cached version of payment processor.
Browse files Browse the repository at this point in the history
I am hitting a slightly obscure bug in Redis that is solved by this change.

Per eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor#55
we have an issue whereby Omnipay adds the gateway to a variable on class when processing payments.

In some cases this gateway will not serialize into a key under Redis causing a fatal.

However, we don't really need it to - the payment processor that we are aiming to cache is
'as loaded' not 'as used'. The caching of the processors appears to have been removed in
the past because of issues around domains -however, I think we can get
past that by changing the cache key.
  • Loading branch information
eileenmcnaughton committed Aug 6, 2018
1 parent 8654960 commit 6689745
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CRM/Financial/BAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public static function defaultComparison($processor1, $processor2) {
*/
public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $isCurrentDomainOnly = TRUE) {

$cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . $mode . '_' . CRM_Core_Config::domainID();
$cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . $mode . '_' . $isCurrentDomainOnly . '_' . CRM_Core_Config::domainID();
if (!$reset) {
$processors = CRM_Utils_Cache::singleton()->get($cacheKey);
if (!empty($processors)) {
Expand Down Expand Up @@ -370,10 +370,10 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i
public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) {
$testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
if (is_array($ids)) {
$processors = self::getAllPaymentProcessors('all', TRUE, FALSE);
$processors = self::getAllPaymentProcessors('all', FALSE, FALSE);
}
else {
$processors = self::getAllPaymentProcessors('all', TRUE);
$processors = self::getAllPaymentProcessors('all');
}

if (in_array('TestMode', $capabilities) && is_array($ids)) {
Expand Down

0 comments on commit 6689745

Please sign in to comment.