Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: convert to module #39449

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open

Blocks: convert to module #39449

wants to merge 6 commits into from

Conversation

kraftbj
Copy link
Contributor

@kraftbj kraftbj commented Sep 18, 2024

Fixes #39351
Fixes #39441
Supercedes and closes #39422

Proposed changes:

  • Drop use of an option for tracking if blocks should be used; deferring to the existing module system.

This will reduce the db calls, since this option is typically not set until someone has toggled it the first time, and convert it to a typical entity.

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

n/a

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

No.

Testing instructions:

A few different things to test. Each should be tested on a clean site (e.g. Nothing Jetpack on it; either new sites or uninstall Jetpack / delete jetpack_options, etc.)

Default new install state (auto-activation of the blocks module)

  • Apply this patch.
  • Setup a regular Jetpack site, site-only connection at least.
  • Verify that the blocks module is active ( /wp-admin/admin.php?page=jetpack_modules )
  • Verify that Jetpack->Settings->Writing has the Blocks option toggled on.
  • Verify that the post block editor has the Jetpack blocks.

Existing site (auto-activation of a newly defined module)

  • On a stable Jetpack, site-only connection.
  • Verify there is no blocks module ( /wp-admin/admin.php?page=jetpack_modules )
  • Using the beta plugin, update Jetpack to this branch.
  • Check the same as above to ensure the module is activated on upgrade.

Existing site with the option previously set true (confirms the module does not activate to respect previous setting and the old option has been deleted to clean up after ourselves.

  • On a stable Jetpack, site-only connection at least.
  • Either directly set the option (e.g. wp option set jetpack_blocks_disabled true) or visit Jetpack->Settings->Writing and toggle the block option.
  • Go to the post editor to confirm blocks are not loading.
  • Update to this branch.
  • Verify that the blocks module is NOT active ( /wp-admin/admin.php?page=jetpack_modules )
  • Verify that Jetpack->Settings->Writing has the Blocks option toggled OFF.
  • Verify that the post block editor DOES NOT have the Jetpack blocks.
  • Verify the previous option was deleted wp option get jetpack_blocks_disabled should return Error: Could not get 'jetpack_blocks_disabled' option. Does it exist?

Existing site with the option previously set false. (if someone had previously disabled and re-enabled; verifies that the modules are active to match previous setting and option has been deleted to clean up)

  • On a stable Jetpack, site-only connection at least.
  • Either directly set the option (e.g. wp option set jetpack_blocks_disabled false) or visit Jetpack->Settings->Writing and toggle the block option to disable and then re-enable the blocks.
  • Go to the post editor to confirm blocks are loading.
  • Update to this branch.
  • Verify that the blocks module is active ( /wp-admin/admin.php?page=jetpack_modules )
  • Verify that Jetpack->Settings->Writing has the Blocks option toggled on.
  • Verify that the post block editor has the Jetpack blocks.
  • Verify the previous option was deleted wp option get jetpack_blocks_disabled should return Error: Could not get 'jetpack_blocks_disabled' option. Does it exist?

@kraftbj kraftbj added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Focus] Performance [Status] In Progress [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack DO NOT MERGE don't merge it! labels Sep 18, 2024
@kraftbj kraftbj self-assigned this Sep 18, 2024
Copy link
Contributor

github-actions bot commented Sep 18, 2024

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 WordPress.com Simple 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, and enable the add/blocks-module branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/blocks-module
    

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 added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Admin Page React-powered dashboard under the Jetpack menu labels Sep 18, 2024
Copy link
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 Team 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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? 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 semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for October 1, 2024 (scheduled code freeze on September 30, 2024).

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

@kraftbj kraftbj added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress DO NOT MERGE don't merge it! labels Sep 19, 2024
@kraftbj kraftbj added this to the jetpack/13.9 milestone Sep 19, 2024
@kraftbj kraftbj marked this pull request as ready for review September 19, 2024 02:01
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Should we add an upgrade routine to the plugin_upgrade method in the big Jetpack class, and 1) turn the module on unless the option was set to false 2) delete the function?

This would ensure that blocks continue to work on sites that were using them, regardless of module auto-activation settings that may have been overwritten with the jetpack_get_default_modules filter.

projects/plugins/jetpack/modules/blocks.php Outdated Show resolved Hide resolved
@kraftbj
Copy link
Contributor Author

kraftbj commented Sep 19, 2024

With plugin_upgrade, do you have a thought on how to ensure we only do it once? The default state for this option is to not exist, so we want to activate it only one if the option is false and delete the option. But, we'd also need to activate Is on not existing.

  1. update one -- option doesn't exist, so we activate blocks (yay)
  2. site admin deactivates blocks via the module construct
  3. next time the update routine runs, do nothing.
    The default module system takes care of that with checking for previous version. Would a check on $version be enough, e.g. older version is before 13.9, activate (or not), and delete?

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

The default state for this option is to not exist, so we want to activate it only one if the option is false and delete the option.

Do we really need to delete the option right away? What if we leave it existing as long as it's true, only deleting it if the module someday gets activated?

In that case we might be able to use the 'jetpack_get_default_modules' filter ourself to exclude the module from the list for as long as that option is set, instead of putting a special case inside of activate_default_modules().

$return = true;

if ( ! ( new Modules() )->is_active( 'blocks' ) ) {
$return = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I note this is a behavior change, before the 'jetpack_gutenberg' was only able to disable the feature, not enable it. Now it can do both.

If it's intentional, it might be worthwhile updating the filter docs below.

projects/plugins/jetpack/modules/blocks.php Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Focus] Performance [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
3 participants