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
Multiple EDD_Payments_Query's affect each other. #5346
Comments
Let's look at this soon after 2.7. |
One other approach might be to unhook the edd_pre_get_payments hooks created by the class by hooking to edd_post_get_payments and unhooking the calls there. |
Hi Pippin, |
I've bumped it to 2.7.3. |
@pippinsplugins Do we have a preferred method for fixing this? The method proposed by @mintplugins in the initial issue seems cleanest to me. |
@ghost1227 go with @mintplugins's proposal. |
With guidance from @ghost1227 I'm going to take a shot at this |
@mintplugins If you have any questions/need help feel free to ping me! |
This is working in my tests but could definitely use more tests. Try anything/everything that would use a payment query. |
I've run multiple tests and all good here but would still like prefer final review from @pippinsplugins or @cklosowski |
Another 👍 from me! |
👍 here |
Merged! |
If you instantiate 2 objects of EDD_Payments_Query, because the values are hooked to edd_pre_get_payments, any custom values you set up for the first object continue to be hooked for any subsequent objects.
For example:
The following code snippet will cause the payment history page in the WordPress dashboard to show no results (notice how we don't return any values or do anything with our returned data here - in theory, because of the word "get", this shouldn't be affecting anything):
The problem is that in the EDD_Payments_Query class, the values are hooked to edd_pre_get_payments. So when the payment history page runs this in a separately instatiated object, the hook still runs which sets the "end_date" - even though we had no intention of setting the end_date for the Payment History page.
Proposed Solution:
Instead of hooking the custom values to edd_pre_get_payments, we should simply call each method from within the get_payments method in EDD_Payments_Query.
The text was updated successfully, but these errors were encountered: