-
Notifications
You must be signed in to change notification settings - Fork 800
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
Sync: add a new method, do_only_first_initial_sync #21676
Conversation
Do not run an initial sync when these two conditions are true: - The site is not registering. - An initial sync has been run before. This change will allow plugins to run an initial sync outside of the site registration process. For example, if a plugin starts using sync after an update, it can run an initial sync to get the cache site up to date. However, this isn't necessary if another plugin has already run an initial sync.
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
115d369
to
cb73696
Compare
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.
Question on the additional action/is_started check
} | ||
|
||
// Don't start a new sync if the site isn't registering and an initial sync was already started. | ||
if ( ! doing_action( 'jetpack_site_registered' ) && $full_sync_module->is_started() ) { |
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.
@kbrown9 can you outline why this check on 'jetpack_site_registered' is added? Logically it does make sense but it is a departure from existing functionality where the action 'jetpack_user_authorized' can also trigger do_initial_sync.
Also won't this check on is_started cause issues with sites that delete Jetpack than re-install?
Would it make sense to add flag of $strict or similar that would preserve existing flow and then add this if statement only if strict is true? This way WC Pay can call do_initial_sync( true )
and get the flow they want but not change existing flows?
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 like your proposal to add a flag. I think an even better approach would be to introduce a new method, Actions::do_only_first_initial_sync
, which consumer plugins could call when they want an initial sync run only when one has never been run before.
The Actions::do_intial_sync
method is hooked to a few actions, and the jetpack_site_registered
action passes a few arguments to the callback functions. We specify that Actions::do_initial_sync
accepts 0 arguments from the action hook here, but if that ever needed to change, I think we would run into problems.
I think introducing the new Actions::do_only_first_initial_sync
method will be both clearer and safer than adding a flag to the existing Actions::do_intial_sync
method. What do you think of this approach?
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 agree a new method is cleaner and safer for usage. 👍 from me on this approach
* Fix the unit tests.
…or_initial_sync_check
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.
Thanks for the great test instructions. Verified and now Approving.
* master: (22 commits) VideoPress: reload block on rating change (#21653) Assets: Changelog for package version 1.12.0 (#21744) assets: Add `wp_register_script` wrapper (and then use it everywhere) (#21689) eslint-config-target-es: Configure mirror repo (#21731) Use monorepo `validate-es` script to validate Webpack builds (#21729) Backup: Replace daily backup references/upsell links with new real-time products (#21715) Likes: reimplement non-admin portions without jQuery (#21726) Autoloader: Not activated autoload queue is false (#21517) Sync: add a new method, do_only_first_initial_sync (#21676) webpack-config: Configure minifier to preserve translator comments (#21667) webpack-config: Use `@automattic/babel-plugin-preserve-i18n` (#21700) Create eslint-config-target-es JS package (#21660) webpack-config: Fork calypso-build's mini-css-with-rtl plugin (#21595) Allow /sites/${site}/external-media/copy/pexels to insert post meta data (#21659) jetpack: Don't set Webpack's `output.pathinfo` in production builds (#21727) Boost: Implement support for loading stylesheets when JavaScript is disabled in the context Critical CSS being enabled (#21713) RNA: export the Connection store (#21388) Display notice when user has unactivated product license keys (#21474) Gardening: ensure it can use Composer (#21712) Nav Unification: Display the stats sparkline on WP Admin for Atomic sites (#21655) ...
* master: VideoPress: reload block on rating change (#21653) Assets: Changelog for package version 1.12.0 (#21744) assets: Add `wp_register_script` wrapper (and then use it everywhere) (#21689) eslint-config-target-es: Configure mirror repo (#21731) Use monorepo `validate-es` script to validate Webpack builds (#21729) Backup: Replace daily backup references/upsell links with new real-time products (#21715) Likes: reimplement non-admin portions without jQuery (#21726) Autoloader: Not activated autoload queue is false (#21517) Sync: add a new method, do_only_first_initial_sync (#21676) webpack-config: Configure minifier to preserve translator comments (#21667) webpack-config: Use `@automattic/babel-plugin-preserve-i18n` (#21700) Create eslint-config-target-es JS package (#21660) webpack-config: Fork calypso-build's mini-css-with-rtl plugin (#21595) Allow /sites/${site}/external-media/copy/pexels to insert post meta data (#21659) jetpack: Don't set Webpack's `output.pathinfo` in production builds (#21727)
Changes proposed in this Pull Request:
do_only_first_initial_sync
, which is used to trigger an initial full sync only when one hasn't already been performed.Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
started
andfinished
values should be timestamps.wp option get jetpack_sync_full_status
wp shell
, try to start an initial sync as shown below. This should return false because an initial sync has already been run.return Automattic\Jetpack\Sync\Actions::do_only_first_initial_sync();
jetpack_sync_full_status
option:wp option delete jetpack_sync_full_status
wp shell
, try to start an initial sync. This should returnnull
because the full sync was started.return Automattic\Jetpack\Sync\Actions::do_only_first_initial_sync();