Skip to content
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

Merged
merged 1 commit into from
Aug 7, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

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

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.
@civibot
Copy link

civibot bot commented Aug 6, 2018

(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();
Copy link
Contributor Author

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

@eileenmcnaughton
Copy link
Contributor Author

test this please

@seamuslee001
Copy link
Contributor

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.

@seamuslee001
Copy link
Contributor

Merging

@seamuslee001 seamuslee001 merged commit 0be011a into civicrm:master Aug 7, 2018
@seamuslee001 seamuslee001 deleted the caching_pp branch August 7, 2018 04:08
@eileenmcnaughton
Copy link
Contributor Author

Thanks @seamuslee001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants