Skip to content

Conversation

@tbradsha
Copy link
Contributor

@tbradsha tbradsha commented Nov 19, 2025

Closes MONOREP-234

In preparation to running static analysis against old Woo 7.0 stubs, this PR addresses some existing issues. In most cases we just add Phan suppressions (see phan/phan#1204). However, Sync had two real compatibility fixes:

  • 9339cac: we referenced some class constant that might not be present; I've changed those instances to use the relevant strings
  • 4bcb8d6: we called a method that may not always exist; I've added a check

Proposed changes:

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

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

Testing instructions:

CI should be happy here, but also Phan should run against old Woo stubs with no errors:

composer require --dev "php-stubs/woocommerce-stubs:7.0"
pnpm jetpack phan --all

@tbradsha tbradsha requested review from a team November 19, 2025 18:46
@tbradsha tbradsha self-assigned this Nov 19, 2025
@tbradsha tbradsha added [Status] Needs Review This PR is ready for review. [Type] Janitorial labels Nov 19, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

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

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
Copy link
Contributor

github-actions bot commented Nov 19, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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

jp-launch-control bot commented Nov 19, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/woocommerce-analytics/src/class-woo-analytics-trait.php 0/268 (0.00%) 0.00% 1 ❤️‍🩹

Full summary · PHP report · JS report

Copy link
Contributor

@coder-karen coder-karen left a comment

Choose a reason for hiding this comment

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

I would say the Sync package changes look fine, however it'd be good for Ventures to confirm that too as the relevant code adder (I see they're included as reviewers).

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.

Looks reasonable from a monorepo perspective. Up to Ventures or whoever about the constant thing.

private function get_product_cogs_data( $ids, $order = '' ) {
$is_cogs_enabled = class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) && \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'cost_of_goods_sold' );
// @phan-suppress-current-line UnusedPluginSuppression @phan-suppress-next-line PhanUndeclaredClassReference, PhanUndeclaredClassMethod -- we're checking for the class and method before using them. See also: https://github.com/phan/phan/issues/1204
$is_cogs_enabled = class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) && method_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil', 'feature_is_enabled' ) && \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'cost_of_goods_sold' );
Copy link
Contributor

Choose a reason for hiding this comment

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

The extra method_exists check seems unnecessary here as the feature_is_enabled was added since the creation of the FeaturesUtil class: https://github.com/woocommerce/woocommerce/pull/34727/files#diff-f5ea913d075d5ad173fcb2099d072ce0bf286922e41a3131442ab99c6ae58263

$product_type = 'variation';
} elseif ( 'product' === $post_type ) {
$product_type = $product_types[ $post->ID ] ?? ProductType::SIMPLE;
$product_type = $product_types[ $post->ID ] ?? 'simple';
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine! I guess we haven't run into any issues here yet, because sync runs on newer stores? or maybe sync has a different plugin requirement?

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.

5 participants