Skip to content

Jetpack Sync: REST_Endpoints - Add clear-queue endpoint#47303

Merged
coder-karen merged 7 commits intotrunkfrom
add/sync-class-rest-api-endpoints-clear-queue
Feb 25, 2026
Merged

Jetpack Sync: REST_Endpoints - Add clear-queue endpoint#47303
coder-karen merged 7 commits intotrunkfrom
add/sync-class-rest-api-endpoints-clear-queue

Conversation

@coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Feb 24, 2026

Fixes SYNC-257

Proposed changes:

  • This PR adds a new clear-queue Sync endpoint, that can be used to clear a queue. Also, if the TEMP_SYNC_DISABLE_TRANSIENT_NAME transient was set during incremental sync we want to delete it, in order to re-enable sending.
  • This PR does not add the functionality needed on WPCOM to use the endpoint (testing instructions include a basic function to test with).
  • Note that we're not including the immediate 'queue' as this is just used as a pathway into Full_Sync_Immediately

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

n/a

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

  • To test, apply this PR on a Jetpack-connected, Jetpack API sandboxed self-hosted site.
  • On WPCOM while sandboxed, add a new reset_queue function in class.jetpack-sync-manager.php:
	function reset_queue() {
		if ( $this->is_jetpack_sync_rest_supported() ) {
			$response = $this->call_core_api( 'POST', '/jetpack/v4/sync/clear-queue' );

			if ( is_wp_error( $response ) ) {
				return $response;
			}
			return (array) $response;
		}
	}
  • To get some items in the queue, add the WP Dummy Content Generator and generate about 100 posts.
  • Then run the following via wpsh to confirm a successful response from the API:
switch_to_blog(YOURBLOGID);
$jsm = new Jetpack_Sync_Manager( get_current_blog_id() );
$result = $jsm->reset_queue();
var_export($result);
  • You should see an array showing that success is true.
  • The queue should also appear to reset in the debugger (incremental queue section).

Changelog

  • Generate changelog entries for this PR (using AI).

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/sync-class-rest-api-endpoints-clear-queue branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/sync-class-rest-api-endpoints-clear-queue
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/sync-class-rest-api-endpoints-clear-queue

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: March 3, 2026
    • Code freeze: March 3, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control
Copy link

jp-launch-control bot commented Feb 24, 2026

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/sync/src/class-rest-endpoints.php 355/497 (71.43%) 1.01% 0 💚
projects/packages/sync/src/class-queue.php 57/193 (29.53%) 1.04% -2 💚
projects/packages/sync/src/sync-queue/class-queue-storage-options.php 36/96 (37.50%) 6.25% -6 💚

Full summary · PHP report · JS report

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Feb 24, 2026
@coder-karen coder-karen marked this pull request as ready for review February 25, 2026 08:41
@coder-karen coder-karen requested a review from a team as a code owner February 25, 2026 08:41
@coder-karen coder-karen requested review from Copilot and removed request for a team February 25, 2026 08:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new REST endpoint /jetpack/v4/sync/clear-queue that allows clearing Jetpack Sync queues ('sync' or 'full_sync'). When the incremental sync queue is cleared, the endpoint also deletes the temporary sync disable transient to re-enable sending, which is important for maintaining proper sync flow after queue operations.

Changes:

  • Added clear_queue REST endpoint for clearing sync and full_sync queues
  • Added comprehensive test coverage including valid queue names and invalid queue rejection
  • Added changelog entries for both the Jetpack plugin and sync package

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
projects/packages/sync/src/class-rest-endpoints.php Implements the clear_queue endpoint with validation for queue names and transient cleanup for incremental sync
projects/packages/sync/tests/php/REST_Endpoints_Test.php Adds tests for successful queue clearing, invalid queue rejection, and permission verification
projects/plugins/jetpack/changelog/pr-47303 Changelog entry for Jetpack plugin
projects/packages/sync/changelog/pr-47303 Changelog entry for sync package

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public static function clear_queue( $request ) {
$queue_name = $request->get_param( 'queue' );

if ( ! in_array( $queue_name, array( 'sync', 'full_sync' ), true ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is applicable / makes sense for full_sync 🤔
Since we no longer use a Full Sync Queue, rather send actions immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I modelled this off unlock_queue, but it would seem that needs updating as well?

@coder-karen coder-karen added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Feb 25, 2026
Copilot AI review requested due to automatic review settings February 25, 2026 11:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 25, 2026 12:22
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@fgiannar fgiannar added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coder-karen coder-karen merged commit d677d01 into trunk Feb 25, 2026
104 checks passed
@coder-karen coder-karen deleted the add/sync-class-rest-api-endpoints-clear-queue branch February 25, 2026 14:07
@github-actions github-actions bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Feb 25, 2026
@github-actions github-actions bot added this to the jetpack/15.6 milestone Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Sync [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants