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

always register private AJAX action to prevent error 400 if logged-in #159

Merged
merged 1 commit into from Jun 7, 2020

Conversation

stklcode
Copy link
Contributor

@stklcode stklcode commented Jun 6, 2020

Fixes an issue that has been reported in WP support forums (switches to German at comment 4):
https://wordpress.org/support/topic/statify-causes-400-error-admin-ajax-php/

Steps to reproduce:

  • JavaScript tracking enabled
  • Tracking disabled for logged-in users (default)
  • Visit the site while logged-in

Behavior:
The Statify JS snippet calls the admin-ajax.php endpoint for logged-in users. This request results in error code 400 (invalid request, because the action does not exist).

Impact:
In most cases, the visit counts are not affected. If tracking is disabled for logged-in users, the visit is not counted anyway. However the log gets messed up with unnecessary errors.

If custom logic has been used to track logged-in users (necessary before 1.7 because there was no option for that), this does not work anymore!

Solution:
Always register the private AJAX action and rely on _skip_tracking() to not count the visits.

If logged-in users are excluded from tracking (default), we did not
register the private AJAX action, which raises an error 400 with JS
tracking enabled.
Does not affect the visit count, but the erroneous request should not
mess up the server logs.
@stklcode stklcode added this to the 1.7.2 milestone Jun 6, 2020
@stklcode stklcode added the bug label Jun 6, 2020
@stklcode
Copy link
Contributor Author

stklcode commented Jun 7, 2020

@patrickrobrecht already suggested this change in #142 (comment), most likely none of us had this impact in mind... 😐

@patrickrobrecht patrickrobrecht merged commit 579a97e into master Jun 7, 2020
@patrickrobrecht patrickrobrecht deleted the fix/ajaxTrackingLoggedIn400 branch June 7, 2020 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants