Skip to content

Conversation

@bindlegirl
Copy link
Contributor

@bindlegirl bindlegirl commented Jan 15, 2026

The new re-validation logic for IDC introduced two new parameters in the IDC error array that define the last checked timestamp and the progressive delay for the next validation attempt. This PR adds logic that makes sure these two parameters are inherited when a new IDC error is generated (by a new remote request).

Closes CONNECT-139

Proposed changes:

  • If the core reason for IDC is still valid (wpcom URLs don't match, we rewrite the existing error but keep the delay and timing parameters.
  • The timing gets updated if the wpcom URLs are the same in the new error as they are in the existing one but the delay stays the same.

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

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

Testing instructions:

  • This can be tough to test, so code review should do.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 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/idc-preserve-revalidation-params branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/idc-preserve-revalidation-params
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/idc-preserve-revalidation-params

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 15, 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!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jan 15, 2026
@jp-launch-control
Copy link

jp-launch-control bot commented Jan 15, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/connection/src/identity-crisis/class-identity-crisis.php 282/394 (71.57%) 1.30% 2 ❤️‍🩹

Full summary · PHP report · JS report

@bindlegirl bindlegirl self-assigned this Jan 15, 2026
@bindlegirl bindlegirl added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jan 15, 2026
@bindlegirl bindlegirl marked this pull request as ready for review January 15, 2026 12:25
Copilot AI review requested due to automatic review settings January 15, 2026 12:25
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 introduces logic to preserve the re-validation timing parameters (last_checked and next_check_delay) when a new IDC (Identity Crisis) error is generated from a remote request. The changes ensure that if the underlying cause of the IDC remains the same (matching wpcom URLs), the backoff delay is preserved while the timestamp is updated. If the wpcom URLs differ, both timing parameters are reset to initial values.

Changes:

  • Updated check_response_for_idc() to preserve timing parameters when wpcom URLs match
  • Added has_same_wpcom_urls() helper method to compare wpcom URLs between existing and new IDC errors
  • Added comprehensive test coverage for the new timing preservation logic

Reviewed changes

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

File Description
projects/packages/connection/src/identity-crisis/class-identity-crisis.php Implements logic to preserve next_check_delay when same wpcom URLs are detected, and resets timing when URLs differ
projects/packages/connection/tests/php/identity-crisis/Identity_Crisis_Test.php Adds four test methods covering preservation, reset, and initial setting of timing parameters
projects/packages/connection/changelog/update-idc-preserve-revalidation-params Adds changelog entry for the feature

@bindlegirl bindlegirl requested a review from sergeymitr January 15, 2026 12:54
@bindlegirl bindlegirl requested a review from a team January 16, 2026 08:58
fgiannar
fgiannar previously approved these changes Jan 16, 2026
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.

Approving after our Slack convo: p1768559411003029-slack-C05PV073SG3 👍

@sergeymitr If you could also take a look at this one before we merge I'd appreciate it.

Copy link
Contributor

@sergeymitr sergeymitr left a comment

Choose a reason for hiding this comment

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

The code looks good to me, just a small improvement we might want to do.
If the site is messed up enough to trigger this code, it won't hurt to do additional checks.

// Same wpcom URLs - preserve the backoff delay.
// Note: last_checked is already set to time() by get_sync_error_idc_option(),
// which is correct - we want to record that we just saw this error again.
if ( isset( $existing_idc['next_check_delay'] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to check that the value is a valid in case it gets corrupted: a number, and between IDC_VALIDATION_INITIAL_DELAY and IDC_VALIDATION_MAX_DELAY.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. I added the validation and refactored the code a bit for clarity.

Copilot AI review requested due to automatic review settings January 20, 2026 12:32
@bindlegirl bindlegirl force-pushed the update/idc-preserve-revalidation-params branch from 3436d94 to 1bd4131 Compare January 20, 2026 12:32
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 3 comments.

@bindlegirl bindlegirl requested a review from sergeymitr January 20, 2026 13:46
Copy link
Contributor

@sergeymitr sergeymitr left a comment

Choose a reason for hiding this comment

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

Tested using some in-code hacks, works well 👍

@sergeymitr sergeymitr 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 Jan 21, 2026
@bindlegirl bindlegirl merged commit f2918b8 into trunk Jan 21, 2026
95 checks passed
@bindlegirl bindlegirl deleted the update/idc-preserve-revalidation-params branch January 21, 2026 07:53
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Connection [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants