-
-
Notifications
You must be signed in to change notification settings - Fork 142
Description
Describe the bug
When using both the Woocommerce Memberships plugin with GraphQL Woocommerce an infinite loop can occur when a user who has not already been authenticated by WordPress clicks on a transfer session link ex: https://wp.local/transfer-session?session_id=xxxxx&_wc_checkout=xxxxxx
To Reproduce
Steps to reproduce the behavior:
- Have both plugins active
- User must not be currently logged into WP
- Retrieve a checkoutUrl from customer field via GraphQL-woocommerce
- Click on a transfer session link
- Infinite loop should occur
Expected behavior
Infinite loops should not trigger while process_auth_request is executing
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOs Ventura 13.6.1
- Browser Chrome Version 124.0.6367.62 (Official Build) (arm64)
Smartphone (please complete the following information):
- Device: Iphone SE
- OS: iOS 17
Plugin Versions
- WooGraphQL Version: 0.19.0
- WPGraphQL Version: 1.19.0
- WPGraphQL Pro Version: 1.4.1 …
- WordPress Version: 6.4.3
- WooCommerce Version: 8.2.0
- WooCommerce Memberships Version: 1.25.2
Additional context
Here is a pastebin of the stack trace before xdebug bails
https://pastebin.com/6YcbV9iR
What I've determined is that
process_auth_requestwill call eventuallywc_get_endpoint_urlwc_get_endpoint_urlwill eventually trigger thewoocommerce_get_query_varsfilter- This filter will trigger
WC_Memberships::add_query_vars() - WC_Memberships will eventually make a query which will fire
pre_get_postsfilter - WooGraphQL will fire
resolve_request()on thepre_get_postsfilter since its priority1 resolve_request()will eventually callprocess_auth_requestand now we're in an infinite loop
Using the Woocommerce Memberships plugin in conjunction with Woocommerce Subscriptions is a pretty common use-case. In my specific enviroment I retrieving the checkoutUrl for use in a headless react app, therefore our users would not be already authenticated with WordPress. The check in process_auth_request (line 343) does not trigger this issue and the request resolves normally.