strangerstudios / pmpro-pay-by-check

Add a "Pay by Check" option to PMPro levels, and keep members in "pending" status until an admin changes the order status.
https://www.paidmembershipspro.com/add-ons/pmpro-pay-by-check-add-on/
11 stars 27 forks source link

Improving performance by no longer filtering gateway option #99

Closed dparker1005 closed 1 year ago

dparker1005 commented 1 year ago

All Submissions:

Changes proposed in this Pull Request:

In the last update, we began using the pmpro_getLevelAtCheckout() function to avoid pulling level IDs directly from the $_REQUEST variable. This came with some performance issues where some sites were running out of PHP memory. Looking at the backtrace for a site, the issue originated from the pmpropbc_pmpro_get_gateway() function.

The first thought here was to try to make that function more efficient by using caching or limiting when it runs, but taking a step back, that plugin seems unnecessary altogether. The pmpropbc_pmpro_get_gateway() function only actually ever has an effect if the level being purchased is a "pay by check only" level. Levels that can be purchased via check or another gateway do not use this code and work correctly. So the pmpropbc_pmpro_get_gateway() function does not actually seem necessary and is clearly a liability.

This PR proposes deprecating the pmpropbc_pmpro_get_gateway() function entirely and instead switching to using the method that is already being used by levels that can be paid for by both check or another gateway, which is also the same method that is used in the Add PayPal Express Add On.

Other information:

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.