Skip to content
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

gw-cache-buster.php: Fixed issue with Cache Buster not clearing cookies with Paypal checkout and Nested entry. #849

Merged
merged 3 commits into from
Jul 4, 2024

Conversation

saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/2630007391/67768/

Summary

When Cache Buster is enabled, Nested Form fields are not being cleared when paying for a form using PayPal.

Loom demonstrating the issue: https://www.loom.com/share/4816b6c7728a416083cfc706b28ff54a?sid=540ba7fe-133d-4e13-b4fb-b00912b4a181

When we submit form with Stripe checkout, GPNF_Session::get_session_path gets the correct session path, however, the same on paypal isn't true. It gets an empty session path. GPNF_Session::delete_cookie(L180) relies on getting correct cookie to delete it. Since, the session path isn't correct with paypal it fails. This only happens with Cache Buster.

xDebug snapshot with Stripe:
stripe

xDebug snapshot with Paypal:
paypal

The fix proposed here is to ensure we have removed all cookies for that form in cache buster scenario.

…kies with Paypal checkout and Nested entry.
@saifsultanc saifsultanc added the bug Something isn't working label Jun 24, 2024
Copy link
Contributor

@claygriffiths claygriffiths left a comment

Choose a reason for hiding this comment

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

This would nuke cookies for GPNF every time you load a form that is being cached-busted.

Can you do a Git bisect on GPNF to narrow down what the cause is if it used to work?

@saifsultanc
Copy link
Contributor Author

This would nuke cookies for GPNF every time you load a form that is being cached-busted.

Can you do a Git bisect on GPNF to narrow down what the cause is if it used to work?

The cause is this commit: https://github.com/gravitywiz/gp-nested-forms/commit/89f3f8ec54618ea8f163e5d07cd6d9a5e25d37be

where we added get_session_path in the GPNF Session implementation. It used to work normally before this version

So Cache Buster with this form setup worked fine till GPNF 1.1.34, and broke with v1.1.35.

@claygriffiths

…kies with Paypal checkout and Nested entry.
@saifsultanc saifsultanc requested a review from spivurno July 3, 2024 06:35
Copy link
Contributor

@spivurno spivurno left a comment

Choose a reason for hiding this comment

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

Looks good!

Approved as is but if you're feeling inspired, it'd be great to to pull the array of query args out of the function so that we only add gpnf_context property if class_exists( 'GPNF_Session' ) rather than setting it every time only setting the path it it exists.

…kies with Paypal checkout and Nested entry.
Copy link

github-actions bot commented Jul 4, 2024

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against 600238d

@saifsultanc saifsultanc merged commit 85d41b9 into master Jul 4, 2024
3 checks passed
@saifsultanc saifsultanc deleted the saif/fix/67768-fix-gpnf-cookie-paypal- branch July 4, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

3 participants