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

WPCOMSH: Post transfer action to conditionally enable HPOS on WooCommerce sites #38119

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

markbiek
Copy link
Contributor

@markbiek markbiek commented Jun 28, 2024

Related to 1468

Proposed changes:

Along with D153524-code, this adds a more general fix for the issue where some WooCommerce sites did not have HPOS enabled after the Atomic transfer.

This adds a new post-transfer action which checks to see if HPOS needs to be enabled for the site and enables it.

Other information:

  • [NA] 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:

Note that we can't do a complete end-to-end test until this PR and the corresponding WPCOM diff (D153524) have been deployed. Once these both ship, the functionality will be gated to Serenity users and we can do a full test and remove the gate.

Setup

  1. Go to https://wordpress.com/setup/free and create a new site.
  2. Continue through the site flow. It doesn't matter if you launch the site or not.
  3. Locate the site id and add the site as an Atomic dev blog (transfer to Atomic dev server pool).
  4. Go to the site dashboard and upgrade to an Entrepreneur plan.
  5. Go to the Hosting Config (https://wordpress.com/hosting-config/yourtestsite.wpcomstaging.com) and ensure that ssh is enabled.
  6. SSH into your site and check to see if HPOS is enabled (wp wc hpos status). If it's enabled, disable it by running wp wc hpos disable.

Testing

  1. Apply D153524-code to your sandbox and sandbox the public-api.
  2. Check out this branch (1468-update/hpos-wpcomsh-wpcli) to the Jetpack project on your local machine.
  3. From within the Jetpack project run jetpack rsync wpcomsh yourtestsite.wordpress.com@sftp.wp.com:htdocs/wp-content/mu-plugins (replace yourtestsite with the actual name of your test site) to copy the wpcomsh changes to your WoA site.
  4. SSH into your site and run wp shell.
  5. In the wp shell, run do_action( 'wpcomsh_woa_post_transfer', array(), array( 'enable_woocommerce_hpos' => true ) );.
  6. Verify that the command runs without errors.
  7. Use CTRL-D to exit the wp shell (this ensures PHP shutdown runs and we send the appropriate messages to logstash.
  8. Run wp wc hops status and verify that HPOS is now enabled.
  9. Go to logstash (d15a40a7e6287357551d44cc5a806099-logstash) and verify that you see a success message for your blog id.
@markbiek markbiek self-assigned this Jun 28, 2024
@markbiek markbiek force-pushed the 1468-update/hpos-wpcomsh-wpcli branch from 8e96c92 to 5648b70 Compare June 28, 2024 18:07
Copy link
Contributor

github-actions bot commented Jun 28, 2024

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.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Wpcomsh plugin:

  • Next scheduled release: August 6, 2024.
  • Scheduled code freeze: July 29, 2024.

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

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jun 28, 2024
@markbiek markbiek requested review from a team and a8caustin June 28, 2024 18:11
@markbiek markbiek changed the title 1468 update/hpos wpcomsh wpcli Jun 28, 2024
@markbiek markbiek force-pushed the 1468-update/hpos-wpcomsh-wpcli branch 2 times, most recently from 8076320 to cd5b714 Compare June 28, 2024 18:36
a8caustin
a8caustin previously approved these changes Jun 28, 2024
projects/plugins/wpcomsh/woa.php Outdated Show resolved Hide resolved
projects/plugins/wpcomsh/woa.php Outdated Show resolved Hide resolved
}

// Enable HPOS
$result = WP_CLI::runcommand(
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, can we make a more direct call for this? It may be worth going via WP_CLI for this one, as getting the general load status right for WooCommerce may be easier from the CLI command than from "raw" code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate a little? We're already using the WP_CLI in this case so I'm not sure what the change would be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some digging and the wc hpos enable command has quite a bit going on behind this scenes (as does manually enabling HPOS from the settings).

https://github.com/woocommerce/woocommerce/blob/d4438a883397b5a72617dc511bb387d380cfe7ff/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php#L754

My inclination is to leave this as a WP_CLI command.

@markbiek markbiek force-pushed the 1468-update/hpos-wpcomsh-wpcli branch from f734867 to 93c20c0 Compare July 2, 2024 14:29
@markbiek markbiek added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jul 2, 2024
@markbiek markbiek requested a review from a team July 2, 2024 18:40
@fgiannar fgiannar added [Status] Needs Team Review and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jul 8, 2024
@markbiek markbiek force-pushed the 1468-update/hpos-wpcomsh-wpcli branch from 93c20c0 to 8d69d3a Compare July 8, 2024 15:34
@sixhours
Copy link
Contributor

sixhours commented Jul 8, 2024

I wasn't able to get this to work:

Screenshot 2024-07-08 at 2 18 58 PM

Wondering if I need to do the setup to sandbox SSH execution? 🤔

@markbiek
Copy link
Contributor Author

markbiek commented Jul 9, 2024

I wasn't able to get this to work:

@sixhours I think it's my fault. I changed the flag to enable_woocommerce_hpos and forgot to update the test instructions 🤦 .

The instructions are updated if you wouldn't mind trying again.

@markbiek markbiek force-pushed the 1468-update/hpos-wpcomsh-wpcli branch from 8d69d3a to 7cf045c Compare July 9, 2024 17:39
Copy link
Contributor

@sixhours sixhours left a comment

Choose a reason for hiding this comment

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

That did it :) 👍

@markbiek markbiek merged commit 762e94a into trunk Jul 10, 2024
53 checks passed
@markbiek markbiek deleted the 1468-update/hpos-wpcomsh-wpcli branch July 10, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants