Repository navigation
wpcomsh: Lock the Blaze and Reader switches in My Jetpack where WordPress.com keeps them on - #54815
Conversation
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>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 2 files.
|
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>
CGastrell
left a comment
There was a problem hiding this comment.
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
initpriority 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
Fixes JETPACK-3624
Proposed changes
feature-plugins/blaze.php) and the WordPress.com Reader (feature-plugins/wpcom-reader-link.php) back on atiniton every request. Turning either off in My Jetpack › Features said "deactivated" and returned 200, and the next request turned the module back on.jetpack_active_modules.Jetpack_Modules_Overridesthen reports it as forced on,/jetpack/v4/module/allcarriesoverride: 'active', and Features locks the switch with "Enabled by your host or site administrator". A REST deactivate gets 409module_forcedinstead of 200.Jetpack::load_modules()runs atafter_setup_theme, before wpcomsh'sinitfilter, so an unsaved module would read as on but never load or fire its activation hooks.jetpack_feature_policy: aforced-onpolicy never saves the module, reads as active even when activation fails, and has to be registered beforeafter_setup_theme. Activating and then reporting keeps today's saved state.Jetpackstand-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'Jetpackclass, 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 apre_option_wpcom_admin_interfacefilter, 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):
POST /jetpack/v4/module/blaze/activewith{"active":false}returns 409module_forced.wp option updatedoesn't change it where the site's persistent data sets the interface; confirm withwp 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