-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use cached version of payment processor. #12627
Conversation
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.
(Standard links)
|
@@ -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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could drop off domain if not current domain only - but I think any benefit from that is negligible & on balance this feels slightly safer
test this please |
I have tested this on multisite and was able to load a contribution page on a domain that the payment processor wasn't on and was happy with the change. |
Merging |
Thanks @seamuslee001 |
Overview
Fix issues with retrieving payment processors in Redis
Before
With some processors combined with Redis caching the call to completetransaction fails
After
Complete transaction works even when the gateway has been 'used'
Technical Details
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 to be storing the payment processor in it's 'used' state. The
getAllPaymentProcessor function is intended to retrieve 'fresh' copies - but in https://github.com/civicrm/civicrm-core/pull/9371/files#diff-de613d42f9ac91739e1d5df2d835af67R381 the caching was by-passed by @seamuslee001 to protect multidomain weirdness -however, I think we can get
past that by changing the cache key.
Comments
@seamuslee001 any chance you can test this? @mattwire ping
@totten ping - just an FYI that there is an issue with Redis that caching objects can crash it sometimes