Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix: add supported subscriptions features before checking for existing attached hooks #4135

Merged
merged 4 commits into from
Mar 28, 2025

Conversation

Mayisha
Copy link
Contributor

@Mayisha Mayisha commented Mar 24, 2025

Fixes #4014 (comment)

Changes proposed in this Pull Request:

  • Added supported subscription features before checking for existing attached hooks.

Testing instructions

  • Code review.

@Mayisha Mayisha marked this pull request as draft March 24, 2025 19:07
@Mayisha
Copy link
Contributor Author

Mayisha commented Mar 24, 2025

@diegocurbelo do you see any possible issues if we move the self::$has_attached_integration_hooks check after declaring the supported features? 👀

@diegocurbelo
Copy link
Member

@diegocurbelo do you see any possible issues if we move the self::$has_attached_integration_hooks check after declaring the supported features? 👀

None, I like the solution, it won't affect what we fixed in #4014

@Mayisha Mayisha marked this pull request as ready for review March 25, 2025 08:32
@kaushikasomaiya
Copy link
Contributor

Thanks for working on this!
I do have one question in mind - the check was to protect against double attachment of payment hook and I guess without the check, $this->supports was being declared twice as well which wasn't an issue however no declaration makes me wonder if the woocommerce_scheduled_subscription_payment_ hook would also be getting skipped due to the check now?

@diegocurbelo
Copy link
Member

Thanks for working on this! I do have one question in mind - the check was to protect against double attachment of payment hook and I guess without the check, $this->supports was being declared twice as well which wasn't an issue however no declaration makes me wonder if the woocommerce_scheduled_subscription_payment_ hook would also be getting skipped due to the check now?

We want to skip the hooks if this is not the first instance of this class, to ensure we are registering/attaching the hooks only once per payment method (ex woocommerce_scheduled_subscription_payment_sepa_debit).

Having the check before the $this->supports = ... was a mistake because that variable is not static, so subsequent instantiations of the same class would not have it set; everything else in the constructor needs to be skipped as they are all add_actions/add_filters calls.

@Mayisha Mayisha requested a review from diegocurbelo March 26, 2025 18:55
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@Mayisha Mayisha merged commit 14fcd3a into develop Mar 28, 2025
36 checks passed
@Mayisha Mayisha deleted the fix/subs-supported-feature branch March 28, 2025 04:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants