Skip to content

wpcomsh: Lock the Blaze and Reader switches in My Jetpack where WordPress.com keeps them on - #54815

Merged
dhasilva merged 4 commits into
trunkfrom
fix/blaze-switch-forced-on-atomic
Nov 12, 2026
Merged

dhasilva merged 4 commits into
trunkfrom
fix/blaze-switch-forced-on-atomic

Conversation

@dhasilva

@dhasilva dhasilva commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes JETPACK-3624

Proposed changes

  • On Atomic, wpcomsh turns Blaze (feature-plugins/blaze.php) and the WordPress.com Reader (feature-plugins/wpcom-reader-link.php) back on at init on every request. Turning either off in My Jetpack › Features said "deactivated" and returned 200, and the next request turned the module back on.
  • After activating each module, wpcomsh now also adds it through jetpack_active_modules. Jetpack_Modules_Overrides then reports it as forced on, /jetpack/v4/module/all carries override: 'active', and Features locks the switch with "Enabled by your host or site administrator". A REST deactivate gets 409 module_forced instead of 200.
  • The forcing itself is unchanged. Blaze still skips sites on the classic wp-admin interface, which keep a working switch, and a module whose activation fails (for example, no connection) isn't reported.
  • The filter goes on after activation: registered first, the module would already read as active, activation would be skipped, and it would never be saved. Jetpack::load_modules() runs at after_setup_theme, before wpcomsh's init filter, so an unsaved module would read as on but never load or fire its activation hooks.
  • Why not jetpack_feature_policy: a forced-on policy never saves the module, reads as active even when activation fails, and has to be registered before after_setup_theme. Activating and then reporting keeps today's saved state.
  • No feature flag, since this is broken today. The note and the 409 need Jetpack 16.3 or later (My Jetpack: let hosts hide features, and explain forced modules instead of offering a toggle #52505). An older Jetpack shows the switch disabled without a reason, and its REST deactivate still returns 200.
  • Tests share one Jetpack stand-in (tests/lib/class-jetpack-stand-in.php), defined only inside the separate-process tests.

Related product discussion/links

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

No.

Testing instructions

Unit tests:

  • jp docker phpunit wpcomsh -- --filter='BlazeTest|ReaderLinkTest'
  • Each test case runs in its own process with a stand-in Jetpack class, covering: default interface (saved and reported), classic interface with Blaze saved (saved, not reported), activation refused (neither), and for Reader: activation succeeds or is refused. The interface is pinned with a pre_option_wpcom_admin_interface filter, since on the WP Cloud test site the persistent-data filter would override a saved option.

On an Atomic site (needs a wpcomsh build with this change, since WoA runs the released wpcomsh):

  • On the Default admin interface, open My Jetpack › Features. The Blaze Ads and WordPress.com Reader switches are on, disabled, and say "Enabled by your host or site administrator".
  • POST /jetpack/v4/module/blaze/active with {"active":false} returns 409 module_forced.
  • Switch the site to the classic interface in Settings › General › Admin Interface Style. wp option update doesn't change it where the site's persistent data sets the interface; confirm with wp option get wpcom_admin_interface. Reload Features: the Blaze switch works as before, and the Reader switch stays locked, since wpcomsh forces Reader on every interface.

🤖 Generated with Claude Code

dhasilva and others added 3 commits November 11, 2026 16:51
On Atomic sites outside the classic wp-admin interface, wpcomsh turns
Blaze back on at `init`, so the My Jetpack Features switch flipped off,
said "Blaze has been deactivated.", and stayed on. Jetpack could not
tell the module was forced, because the forcing writes the stored
module list instead of filtering `jetpack_active_modules`.

Once the forcing has left Blaze active, add it through
`jetpack_active_modules` as well. `Jetpack_Modules_Overrides` then
reports it as forced on, so the switch is locked with "Enabled by your
host or site administrator", and the module REST endpoint answers a
deactivation with `module_forced` instead of a 200. The filter goes on
after the activation, which would otherwise see Blaze as active and
skip saving it, so the stored list behaves as before.

Refs JETPACK-3624

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wpcomsh turns the `wpcom-reader` module back on at `init` on every
Atomic request, the same way it forces Blaze, so the WordPress.com
Reader switch in My Jetpack › Features had the same flip-back as
JETPACK-3624.

Report it through `jetpack_active_modules` once activation has left it
active, so `Jetpack_Modules_Overrides` locks the switch. As with Blaze,
the filter goes on after activation so the module is still saved.

Refs JETPACK-3624

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs JETPACK-3624

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 11, 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 (WordPress.com Site Helper), and enable the fix/blaze-switch-forced-on-atomic branch.

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 Nov 11, 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!


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

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

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/wpcomsh/feature-plugins/blaze.php 14/45 (31.11%) 12.06% -3 💚
projects/plugins/wpcomsh/feature-plugins/wpcom-reader-link.php 6/12 (50.00%) 50.00% -3 💚

Full summary · PHP report

On the WP Cloud test site, wpcomsh_get_wpcom_admin_interface_option()
answers `pre_option_wpcom_admin_interface` from Atomic_Persistent_Data,
so the test's update_option() had no effect and the classic row failed.
Pin the value with a last-priority `pre_option_` filter instead, which
also keeps the write from syncing to WordPress.com.

Refs JETPACK-3624

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhasilva
dhasilva marked this pull request as ready for review November 11, 2026 21:20
@dhasilva dhasilva added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Nov 11, 2026

@CGastrell CGastrell 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.

Looks good. Checked:

  • get_overrides() reads a module as forced on when the filter adds it to an empty list, so the switch locks and a REST deactivate gets 409.
  • The filter goes on only after a saved activation. get_active() drops unavailable modules before the filter runs, so a saved but unavailable Blaze is not reported.
  • Nothing fills the overrides cache before init priority 0.
  • do_overrides_exist() is now true on every Atomic site (Reader). No caller changes UI on that alone.

Live WoA check will happen on the next JETPACK-3464 run once wpcomsh ships.

Terminator

@dhasilva
dhasilva merged commit 3af1427 into trunk Nov 12, 2026
88 checks passed
@dhasilva
dhasilva deleted the fix/blaze-switch-forced-on-atomic branch November 12, 2026 15:24
@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] Needs Review This PR is ready for review. labels Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Wpcomsh [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.

2 participants