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

use wp_die() instead of header and exit for AJAX requests #160

Merged
merged 3 commits into from
Jun 7, 2020

Conversation

stklcode
Copy link
Contributor

@stklcode stklcode commented Jun 6, 2020

Use WP builtin wp_die() logic with overwritten response code 204 for AJAX jump-out after the tracking action.

This allows other logic to clean up as designed while calling exit directly does not. It also makes integration testing easier (currently working on that).

I cannot remember why the Content-Type: application/javascript was necessary, but I guess it's just a residual artifact from previous logic.

The Content-Type: application/javascript header is not required since the pseudo <script>-tag has been replaced by an explicit XHR call in 1.6.3 (#92), so we can omit it without consequences here. (content type for "no content" does not really make sense anyway)

Use WP builtin wp_die() logic with overwritten response code 204 for
AJAX jump-out after the tracking action.

This allows other logic to clean up as designed while calling exit
directly does not. It also makes unit testing easier.
@stklcode stklcode requested a review from bueltge June 7, 2020 10:07
@bueltge bueltge self-assigned this Jun 7, 2020
@bueltge
Copy link
Member

bueltge commented Jun 7, 2020

So much simpler and better. Need the die a message? If now, please merge them.

@bueltge bueltge assigned krafit and unassigned bueltge Jun 7, 2020
@stklcode
Copy link
Contributor Author

stklcode commented Jun 7, 2020

With status 204 the given message is ignored anyway (just checked, with default 200 it is given in body). So I don't see any reason to pass one.

@patrickrobrecht patrickrobrecht merged commit eab1d2e into master Jun 7, 2020
@patrickrobrecht patrickrobrecht deleted the wp_die branch June 7, 2020 18:25
@stklcode stklcode added this to the 1.7.2 milestone Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants