-
Notifications
You must be signed in to change notification settings - Fork 846
Sync: Full sync the term relationships #13077
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
Conversation
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: August 6, 2019. |
|
This is ready for review now. |
| // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition, WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
| while ( $ids = $wpdb->get_results( "SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id <= {$previous_interval_end['object_id']} AND term_taxonomy_id < {$previous_interval_end['term_taxonomy_id']} ORDER BY object_id DESC, term_taxonomy_id DESC LIMIT {$items_per_page}", ARRAY_A ) ) { | ||
| // Request term relationships in groups of N for efficiency. | ||
| $chunked_ids = array_chunk( $ids, self::ARRAY_CHUNK_SIZE ); |
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.
The bit in the while is kind of the same as the one in Automattic\Jetpack\Sync\Modules\Module::enqueue_all_ids_as_action, so we can eventually refactor them to share the same method, but it feels like this can be done in a follow-up PR, hence the @todo in the docblock.
roccotripaldi
left a comment
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.
This is looking good. Thanks for working on it.
One thing is missing from the testing instructions:
- you need to set JETPACK__API_BASE to your sandbox in jetpack.php
After testing, i realized we had to make a small change to D30623.
It works well when you silently add a term_relationship: I see it appear in the cache site after a full sync.
When i silently delete a term_relationship, the entry remains on the cache site after a full sync.
I think we can fix that on the server-side, so you have my approval.
|
This PR is not needed any more. In D30684-code, we ensured that we were properly getting term relationships during a full sync. |
|
Not 100% sure about closing it, I think it might be useful to have it anyways, even if full syncing posts should fix terms, maybe "fullsyncing" just this table could be faster in some cases, plus we might need some of the logic here for the validator, what do you think? |
|
Let's merge this, even if we don't use it right now, just in case we discover we need to revert to this approach during testing with very large sites on VIP. |
zinigor
left a comment
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.
Although this might need a lint pass after, let's do it in another PR.
* Add initial changelog / testing list changes for 7.6 * Update stable tag to 7.5.3 * changelog: add #12957 * Changelog: add #12932 * Changelog: add #12867 * Changelog: add #12823 * changelog: add #12969 * changelog: add #13012 * changelog: add #12974 * Changelog: add #13059 * Changelog: add #13079 * Changelog: add #12924 * changelog: add #12954 * Changelog: add #12959 * Changelog: add #12977 * Changelog: add #12830 * Changelog: add #12926 * Changelog: add #12958 * Changelog: add #12999 * Changelog: add #13077 * Changelog: add #13083 * Changelog: add #13087 * Changelog: add #13110 * Changelog: add #13116 * Changelog: add #13117 * Changelog: add #12821 * Changelog: add #13120 * changelog: add #13139 * Changelog: add #13143 * Changelog: add #13147 * Testing list: add section about sync
* Add initial changelog / testing list changes for 7.6 * Update stable tag to 7.5.3 * changelog: add #12957 * Changelog: add #12932 * Changelog: add #12867 * Changelog: add #12823 * changelog: add #12969 * changelog: add #13012 * changelog: add #12974 * Changelog: add #13059 * Changelog: add #13079 * Changelog: add #12924 * changelog: add #12954 * Changelog: add #12959 * Changelog: add #12977 * Changelog: add #12830 * Changelog: add #12926 * Changelog: add #12958 * Changelog: add #12999 * Changelog: add #13077 * Changelog: add #13083 * Changelog: add #13087 * Changelog: add #13110 * Changelog: add #13116 * Changelog: add #13117 * Changelog: add #12821 * Changelog: add #13120 * changelog: add #13139 * Changelog: add #13143 * Changelog: add #13147 * Testing list: add section about sync
This implements syncing of the term relationships in full sync, which currently we don't seem to be doing.
Turns out it is a bit specific use case, because that table the only one that doesn't have a unique ID column. So to be able to still chunk properly like we do for other sync modules, we use 2 columns, and wrap the functionality in a new sync module,
Term_Relationships.We're introducing some tests to verify that missing or obsolete term relationships are synced, and add some tests to the full sync to ensure that it's properly syncing all term relationships, and is properly chunking them when there are a lot of them to sync.
Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
WP_DEBUG_LOGon your site if it's disabled.Additional testing help
Proposed changelog entry for your changes: