WIP CRM-21256 Improve performance of payment processor load #11060
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Improve performance of "Submit Credit Card Contribution" page load.
Before
CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting() is being called 4 times (3 for BackOffice, once for futurePayment capability) for a backoffice payment and having quite a noticeable performance impact on the "Submit Credit Card Contribution" form.
After
It's still being called 4 times, but we return the cached (via static var) result on each subsequent call.
Technical Details
Timings from a (slow) site:
Oct 03 17:07:06 [info] exec time old: 1.7639739513397
Oct 03 17:07:07 [info] exec time old: 1.2242529392242
Oct 03 17:07:15 [info] exec time old: 1.2430901527405
Oct 03 17:07:27 [info] exec time old: 1.2307901382446
Oct 03 17:08:27 [info] exec time new: 1.2210669517517
Oct 03 17:08:28 [info] exec time new: 0.72421288490295
Oct 03 17:08:34 [info] exec time new: 7.1525573730469E-6
Oct 03 17:08:44 [info] exec time new: 6.1988830566406E-6