Skip to content

Conversation

@coder-karen
Copy link
Contributor

@coder-karen coder-karen commented Jan 7, 2026

Fixes SYNC-173

Proposed changes:

  • This PR checks that the relevant sync module name key exists in the $progress and $config arrays before attempting to access them. Previously with the warnings we were still processing in send_full_sync_actions (but with empty $status and $config). If we retain the existing behavior and pass null defaults in those cases, we generate more warnings, within class-module.php. So just replicating existing behavior isn't ideal in this case.
  • As an additional improvement, we also now store $module->name() in a variable, reducing repeated method calls.
  • The changes prevent array key warnings such as Undefined array key "woocommerce_hpos_orders", and also Undefined array key "sent" warnings in class-module.php.
  • The reason the warnings would be happening is because the list of modules to be synced has updated during the running of the function, for example when we calculate $config or $progress initially in send, vs when we get modules in get_remaining_modules_to_send.
  • Lastly - a test has been added. We are testing that we start a full sync with a frozen snapshot of modules to process. After that, something adds a module to the full-sync config (which isn't in the frozen snapshot). As such get_remaining_modules_to_send sees the extra module - and we can then test that our new guard prevents calling send_full_sync_actions for that module, but still completes the full sync.

There are two other options here:

  • Freeze the module set for a given full sync - for example in get_remaining_modules_to_send we can ensure we don't continue if $status['progress'][ $module_name ] is not set.
  • Alternatively, update the module set during full sync rather than freezing it - so that $progress and $config have the up to date modules.

Why the current approach instead of these?

  • Preserves existing behavior as much as possible (which also makes it lower risk) without redesigning start/range/ordering logic.
  • The run remains aligned with the jetpack_full_sync_start config/range.
  • We still capture late ongoing changes to existing modules

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

p1763754755558699/1763754199.536589-slack-C05PV073SG3

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

No.

Testing instructions:

To test this out, I found the best approach was to add some code. To replicate the warnings, on trunk add the following code just below the foreach:

if ( $module_name === 'terms' ) {
	unset( $config[ $module_name ] );
	unset( $progress[ $module_name ] );
}

Separately you can also test a module in an unfinished progress state (same location for the code):

if ( $module_name === 'terms' ) {
	static $once = false;
	if ( ! $once ) {
		$progress[ $module_name ]['finished']  = false;
		$once = true;
	}
}

Lastly, we can also test some unusual config set up by adding the following in place of or after the $full_sync_config check in start (we can't set $full_sync_config to null directly as we assume $config exists in places like get_remaining_modules_to_send ):

$full_sync_config = array(
	'constants'          => 1,
	'themes'             => 1,
	'users'              => 1,
	'posts'              => null,
	'comments'           => 1,
	'updates'            => 1,
	'term_relationships' => 1,
);
  • This needs to be added for the relevant file on a Jetpack self-hosted site. You can then run a full sync via the Jetpack debugger (one that includes terms), and you should see the warnings in your error log.
  • To test the fix, follow the same steps but with the PR applied using the Jetpack beta tester plugin, or applied locally. There should not be warnings. All modules should sync as expected.

Running tests:

  • Tests should pass in this PR, but to replicate the test failures and warnings you'd need to copy the test file over to a local development environment, and run jetpack docker phpunit jetpack -- --filter=Jetpack_Sync_Full_Immediately_Test

@coder-karen coder-karen self-assigned this Jan 7, 2026
@coder-karen coder-karen added [Type] Bug When a feature is broken and / or not performing as intended [Status] In Progress [Package] Sync labels Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 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 update/full_sync_immediately-send-check-modules-exist branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/full_sync_immediately-send-check-modules-exist
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/full_sync_immediately-send-check-modules-exist

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 Jan 7, 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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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: February 3, 2026
    • Code freeze: February 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 Jan 7, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/sync/src/modules/class-full-sync-immediately.php 32/195 (16.41%) -1.08% 12 💔

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

@coder-karen coder-karen marked this pull request as ready for review January 8, 2026 09:55
Copilot AI review requested due to automatic review settings January 8, 2026 09:55
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 addresses array key warnings that occur when sync modules are added or removed during a full sync operation. The fix adds checks using the null coalescing operator before accessing module-specific configuration and progress data, and extracts the module name into a variable to reduce repeated method calls.

Key Changes:

  • Adds null coalescing operator checks for module config and progress array keys
  • Stores module name in a variable to avoid repeated $module->name() calls
  • Corrects doc block parameter type from string to array for $config

Reviewed changes

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

File Description
projects/packages/sync/src/modules/class-full-sync-immediately.php Adds array key existence checks and extracts module name to variable
projects/packages/sync/src/modules/class-module.php Corrects parameter type documentation and formatting
projects/packages/sync/changelog/update-full_sync_immediately-send-check-modules-exist Adds changelog entry for the bug fix

@coder-karen coder-karen marked this pull request as draft January 8, 2026 10:18
@coder-karen coder-karen marked this pull request as ready for review January 8, 2026 10:54
Copilot AI review requested due to automatic review settings January 8, 2026 10:54
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 3 out of 3 changed files in this pull request and generated 4 comments.

@coder-karen coder-karen marked this pull request as draft January 8, 2026 17:02
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Jan 9, 2026
@coder-karen coder-karen marked this pull request as ready for review January 9, 2026 12:31
Copilot AI review requested due to automatic review settings January 9, 2026 12:31
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 5 out of 5 changed files in this pull request and generated 3 comments.

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 5 out of 5 changed files in this pull request and generated no new comments.

…ious behavior when a key exists but its value is null
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] In Progress [Tests] Includes Tests [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants