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

Replace Sync AJAX callback with REST API endpoint. #3643

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

JakePT
Copy link
Contributor

@JakePT JakePT commented Sep 19, 2023

Description of the Change

Replaces the admin-ajax.php callbacks used by the Sync page with a REST API. This also adds support for additional arguments that are passed to the index helper:

  • include
  • indexables
  • lower_limit_object_id
  • offset
  • post_type
  • put_mapping
  • upper_limit_object_id

This PR updates the Sync page to use the REST API, but there is no UI for the additional parameters at this stage.

Closes #3627

How to test the Change

  • Sync should function as normal.
  • POST requests to wp-json/elasticpress/v1/sync with the above parameters should perform the expected sync.
  • GET requests to wp-json/elasticpress/v1/sync should return the status of an in progress sync.
  • DELETE requests to wp-json/elasticpress/v1/sync should cancel an in progress sync.

Changelog Entry

Changed - Moved syncing from an admin-ajax.php callback to a custom REST API endpoint with support for additional arguments.

Credits

Props @JakePT

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JakePT I added a small change that we will need. IMHO initializing the REST Sync class in Screen Sync seems out of place... now that we will have it available, that should be a standalone thing, so people who want to build on top of it would be able to (and not depend on any "screen" entity.) Thoughts?

includes/classes/Screen/Sync.php Show resolved Hide resolved
@JakePT JakePT marked this pull request as ready for review September 21, 2023 11:58
@JakePT JakePT changed the title WIP: Replace Sync AJAX callback with REST API endpoint. Replace Sync AJAX callback with REST API endpoint. Sep 21, 2023
@felipeelia felipeelia linked an issue Sep 21, 2023 that may be closed by this pull request
1 task
@felipeelia felipeelia added this to the 5.0.0 milestone Sep 21, 2023
@felipeelia felipeelia merged commit 8e07599 into 5.0.0 Sep 21, 2023
8 of 9 checks passed
@felipeelia felipeelia deleted the feature/sync-rest-api branch September 21, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Sync AJAX callback with REST API endpoint
2 participants