-
Notifications
You must be signed in to change notification settings - Fork 808
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
Don't sync set_object_terms actions that don't update term relationships #17171
Conversation
…m any update. Includes unit tests.
Scheduled Jetpack release: October 6, 2020. E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-17171 Thank you for the great PR description! When this PR is ready for review, please apply the |
E2E Tests were plan related which are not touched in this PR. Merged master to have them re-run. Needs Crew Review. |
Hi @mdbitz, I gave it a go but I need a hand on how to test sync. I'm gonna ask it here because it might be helpful for more people (cc @bisko )
Here's how I was doing it:
But then I checked ou So I followed the same steps again and no action was queued at all. And then all of a sudden I couldn't test it anymore because no actions were being queued. Even if I created a new post, new term, and everything... What's the best way to test it? (sorry for the long comment and holding this, but this will be helpful in future PRs - and I volunteer to expand the Field Guide page on this) |
Hi Leo, you shouldn't have to delete any entries from the queue (options table). When testing sync I recommend that you always have the test site's jetpack connection sandboxed to your WP.com sandbox. https://wp.me/PCYsg-efV . Defining the JETPACK__SANDBOX_DOMAIN constant. This will have all sync activity go to your WP.com sandbox. From this point there are quite a few ways to track Sync Activity.
If you do #3 you don't even need to sandbox the site as that is recorded for every request across all servers. -- If you aren't seeing any items in the options table than most likely they were sent already to WP.com and processed. Sync runs on shutdown so any requests to modify content/view content via web requests will trigger the data being sent. |
Thanks for the info. I made some progress but still can't confirm the original issue on On the environmentFor some reason, setting Testing
The sync is only triggered in my sandbox if a new term is created or if the terms attached to a post change. I also tried using But I did try to run the new test on the |
Ran some tests on my local test site and the reason for unable to duplicate appears to be that the is_staging_site flag is returning true in cli. This stops actions from going to the sync queue and hence not seeing the duplicate actions. You can place the wp_set_post_terms in your functions.php or similar file so that it triggers on every request. Then refresh the site a few times and you'll see the same event being queued and sent to WP.com __ The reason the tests don't have this issue is that we have a specific case to return true in is_sync_enabled for unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was finally able to test it.
The issue was that the Sync server, on WPCOM side, was discarding the requests because it was identifying them as duplicates since they were identical.
So I had to add some additional logging to be able to confirm that, with this branch checked out, no requests were being sent at all.
@jmdodd created a fabulous filter to exclude set_object_terms that were not performing updates.
This patch ensures wp_set_object_terms calls with the same term relations already set on the object will no longer trigger set_object_terms actions to be synced.
Fixes https://wp.me/p9o2xV-12g
Changes proposed in this Pull Request:
Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
NO
Testing instructions:
set_object_terms
action is queued/sent.** You can see the unit test for examples.
Proposed changelog entry for your changes: