Skip to content

Commit ef88ed7

Browse files
tbradshamatticbot
authored andcommitted
Phan: Address issues discovered while testing against old WooCommerce stubs (#46003)
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/19542955828 Upstream-Ref: Automattic/jetpack@a0c74e4
1 parent 16d1e6a commit ef88ed7

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.12.2-alpha] - unreleased
9+
10+
This is an alpha version! The changes listed here are not final.
11+
12+
### Fixed
13+
- Improve compatibility with old WooCommerce versions.
14+
815
## [0.12.1] - 2025-11-19
916
### Fixed
1017
- Fix compatibility issue with WooCommerce older than 9.7.0. [#45988]
@@ -212,6 +219,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
212219
- Fix namespace issue with WooCommerce class reference. [#35857]
213220
- General: bail early when WooCommerce is not active. [#36278]
214221

222+
[0.12.2-alpha]: https://github.com/Automattic/woocommerce-analytics/compare/v0.12.1...v0.12.2-alpha
215223
[0.12.1]: https://github.com/Automattic/woocommerce-analytics/compare/v0.12.0...v0.12.1
216224
[0.12.0]: https://github.com/Automattic/woocommerce-analytics/compare/v0.11.0...v0.12.0
217225
[0.11.0]: https://github.com/Automattic/woocommerce-analytics/compare/v0.10.1...v0.11.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@automattic/woocommerce-analytics",
3-
"version": "0.12.1",
3+
"version": "0.12.2-alpha",
44
"private": true,
55
"description": "WooCommerce Analytics package to track frontend events",
66
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/woocommerce-analytics/#readme",

src/class-wc-analytics-tracking.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public static function send_batched_pixels() {
231231
foreach ( self::$pixel_batch_queue as $pixel ) {
232232
// Check if the method exists for backwards compatibility with older WooCommerce versions.
233233
if ( method_exists( WC_Tracks_Client::class, 'add_request_timestamp_and_nocache' ) ) {
234+
// @phan-suppress-current-line UnusedPluginSuppression @phan-suppress-next-line PhanUndeclaredStaticMethod -- We verify the method exists before using it. See also: https://github.com/phan/phan/issues/1204
234235
$pixels_to_send[] = WC_Tracks_Client::add_request_timestamp_and_nocache( $pixel );
235236
} else {
236237
// Fallback for older versions - add timestamp and nocache parameters manually.
@@ -387,7 +388,7 @@ public static function get_server_details() {
387388
$data = parent::get_server_details();
388389
} elseif ( method_exists( WC_Site_Tracking::class, 'get_server_details' ) ) {
389390
// WC < 6.8
390-
$data = WC_Site_Tracking::get_server_details(); // @phan-suppress-current-line PhanUndeclaredStaticMethod -- method is available in WC < 6.8
391+
$data = WC_Site_Tracking::get_server_details(); // @phan-suppress-current-line PhanUndeclaredStaticMethod -- method is available in WC < 6.8. See also: https://github.com/phan/phan/issues/1204
391392
}
392393

393394
return array_merge(
@@ -413,7 +414,7 @@ public static function get_blog_details( $blog_id ) {
413414
return parent::get_blog_details( $blog_id );
414415
} elseif ( method_exists( WC_Site_Tracking::class, 'get_blog_details' ) ) {
415416
// WC < 6.8
416-
return WC_Site_Tracking::get_blog_details( $blog_id ); // @phan-suppress-current-line PhanUndeclaredStaticMethod -- method is available in WC < 6.8
417+
return WC_Site_Tracking::get_blog_details( $blog_id ); // @phan-suppress-current-line PhanUndeclaredStaticMethod -- method is available in WC < 6.8. See also: https://github.com/phan/phan/issues/1204
417418
}
418419
return array();
419420
}

src/class-woo-analytics-trait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public function find_cart_checkout_content_sources() {
172172

173173
$this->cart_checkout_templates_in_use = wp_is_block_theme()
174174
&& class_exists( '\Automattic\WooCommerce\Blocks\Package' )
175+
// @phan-suppress-current-line UnusedPluginSuppression @phan-suppress-next-line PhanUndeclaredClassMethod -- If the class exists (as of WooCommerce 8.5.0), the method exists. See also: https://github.com/phan/phan/issues/1204
175176
&& version_compare( \Automattic\WooCommerce\Blocks\Package::get_version(), '10.6.0', '>=' );
176177

177178
// Cart/Checkout *pages* are in use if the templates are not in use. Return their content and do nothing else.
@@ -260,6 +261,7 @@ public function find_cart_checkout_content_sources() {
260261
public function get_common_properties() {
261262
$site_info = array(
262263
'blog_id' => Jetpack_Connection::get_site_id(),
264+
// @phan-suppress-current-line UnusedPluginSuppression @phan-suppress-next-line PhanUndeclaredConstantOfClass -- The constant has only existed since WooCommerce 8.4, but we check for its existence. See also: https://github.com/phan/phan/issues/1204
263265
'store_id' => defined( '\\WC_Install::STORE_ID_OPTION' ) ? get_option( \WC_Install::STORE_ID_OPTION ) : false,
264266
'ui' => $this->get_user_id(),
265267
'url' => home_url(),

src/class-woocommerce-analytics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Woocommerce_Analytics {
2121
/**
2222
* Package version.
2323
*/
24-
const PACKAGE_VERSION = '0.12.1';
24+
const PACKAGE_VERSION = '0.12.2-alpha';
2525

2626
/**
2727
* Proxy speed module version.

0 commit comments

Comments
 (0)