Use cached version of payment processor.
authoreileen <emcnaughton@wikimedia.org>
Mon, 6 Aug 2018 06:40:32 +0000 (18:40 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 6 Aug 2018 06:40:54 +0000 (18:40 +1200)
I am hitting a slightly obscure bug in Redis that is solved by this change.

Per https://github.com/eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor/issues/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.

CRM/Financial/BAO/PaymentProcessor.php

index 3054bb464989e11fb7ce2c35a8ea0af17a533842..6b3a722df751262845eab2c8104a5f6159ab115b 100644 (file)
@@ -273,7 +273,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    */
   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)) {
@@ -370,10 +370,10 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   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)) {