Skip to content

Connection: Add the protected_owner option and its storage plumbing - #51254

Merged
bindlegirl merged 1 commit into
trunkfrom
add/protected-owner-option
Aug 13, 2026
Merged

Connection: Add the protected_owner option and its storage plumbing#51254
bindlegirl merged 1 commit into
trunkfrom
add/protected-owner-option

Conversation

@bindlegirl

@bindlegirl bindlegirl commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Closes CONNECT-406

This is PR1 of the Protected Owner series. It is storage plumbing only — nothing reads the option yet, so there is no behavior change.

A Protected Owner is a connection owner whose identity is locked and non-transferable, so ownership-bound consumers bind to the real owner rather than to whoever connected first. It generalizes the ownership lock that today only applies to Atomic sites. This PR just lays down where that state will live.

Proposed changes

  • Register a protected_owner option in Jetpack_Options, in the compact group next to master_user. Compact placement is deliberate: the compact group lives in the single jetpack_options row, which is already on Sync's options allowlist, so a later PR gets outbound Sync of the anchor for free. The anchor holds wpcom_user_id, email, local_user_id, locked, confirmed_at, and confirmed_by.
  • Add it to $external_storage_allowlist so the APD seam can serve it, alongside blog_token, id, master_user, and user_tokens.
  • Add it to the unsafe-options list in get_all_jetpack_options(). That list feeds get_options_for_reset(), so without this the reset tooling would wipe the anchor while the connection itself survived — silently unlocking ownership on a site that still has a Protected Owner.
  • Delete it in Manager::delete_all_connection_tokens(), next to the existing master_user deletion. WordPress.com owns the record; the local anchor is a cache. Dropping it on disconnect stops a site from carrying a lock naming a user who no longer holds a token, and the anchor is re-established from WordPress.com when the owner reconnects.
  • Add Jetpack_Options_Test.php (no such file existed) covering the round-trip, compact-group registration, storage location, deletion, exclusion from the reset list, and the external-storage allowlist — including a negative control proving a non-allowlisted option is never routed to a provider.

Related product discussion/links

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

No. The option is registered but never written or read by this PR. When later PRs populate it, the anchor will contain the connection owner's WordPress.com user ID and email — both already known to WordPress.com.

Testing instructions

This PR has no UI. Verification is that the option is wired up correctly and that nothing else moved.

  • Run the package tests and confirm they pass, including the 7 new ones:
    • jetpack test php packages/connection
    • or directly: cd projects/packages/connection && ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --filter Jetpack_Options_Test
  • On a connected site, confirm the option is registered and compact:
    • wp eval 'var_dump( Jetpack_Options::get_option( "protected_owner" ) );' returns false.
    • wp eval 'Jetpack_Options::update_option( "protected_owner", array( "wpcom_user_id" => 1 ) ); var_dump( get_option( "jetpack_options" )["protected_owner"], get_option( "jetpack_protected_owner" ) );' shows the value inside the jetpack_options row and false for a standalone row.
  • Confirm no behavior change: connect and disconnect a site as usual and verify ownership, the connection owner UI, and reconnection all behave exactly as on trunk.

Made with Cursor

Registers a protected_owner option that will anchor a connection owner whose
identity is locked and non-transferable, so ownership-bound consumers can bind
to the real owner rather than to whoever connected first.

The anchor joins the compact option group next to master_user, which is what
lets Sync propagate it without further work. It is added to the external
storage allowlist for the APD seam, and to the unsafe-options list so the
reset tooling cannot wipe it and silently unlock ownership on a site whose
connection survived. Disconnecting drops it: WordPress.com owns the record,
and the anchor is re-established when the owner reconnects.

Nothing reads the option yet, so behavior is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@bindlegirl bindlegirl self-assigned this Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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/protected-owner-option branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/protected-owner-option
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/protected-owner-option

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

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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 Aug 13, 2026
@jp-launch-control

jp-launch-control Bot commented Aug 13, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/connection/src/class-manager.php 746/1088 (68.57%) 0.03% 0 💚
projects/packages/connection/legacy/class-jetpack-options.php 222/306 (72.55%) 7.09% -21 💚

Full summary · PHP report · JS report

@bindlegirl
bindlegirl marked this pull request as ready for review August 13, 2026 16:49
@bindlegirl
bindlegirl requested a review from a team as a code owner August 13, 2026 16:49
@bindlegirl
bindlegirl requested a lite review from Copilot August 13, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds the initial “storage plumbing” for a new protected_owner connection option in the Connection package, establishing where the state will live and how it’s persisted/cleared, without introducing any behavioral change yet.

Changes:

  • Register protected_owner as a compact Jetpack_Options option and treat it as connection-critical (excluded from reset lists).
  • Allow protected_owner to be served via the external-storage provider seam and ensure it’s cleared on disconnect.
  • Add a dedicated PHPUnit test suite validating compact storage, deletion, reset behavior, and external-storage routing (including a negative control).

Reviewed changes

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

File Description
projects/packages/connection/tests/php/Jetpack_Options_Test.php Adds coverage for protected_owner registration/storage/deletion/reset semantics and external-storage routing behavior.
projects/packages/connection/src/class-manager.php Ensures protected_owner is deleted alongside other connection-critical tokens/options during disconnect.
projects/packages/connection/legacy/class-jetpack-options.php Registers protected_owner in the compact option set, adds it to the external storage allowlist, and marks it unsafe for resets.
projects/packages/connection/changelog/add-protected-owner-option Adds a changelogger entry (comment-only) documenting the plumbing change without a user-facing entry body.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bindlegirl
bindlegirl merged commit c569d9e into trunk Aug 13, 2026
118 checks passed
@bindlegirl
bindlegirl deleted the add/protected-owner-option branch August 13, 2026 17:09
@github-actions github-actions Bot 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 Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants