Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix call to undefined method WC_Tracks::get_server_details()
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Automattic\Woocommerce_Analytics;

use Automattic\Jetpack\Connection\Manager as Jetpack_Connection;
use WC_Site_Tracking;
use WC_Tracks;
use WC_Tracks_Client;
use WC_Tracks_Event;
Expand Down Expand Up @@ -244,7 +245,15 @@ private static function get_blog_user_id() {
* @return array Server details.
*/
public static function get_server_details() {
$data = parent::get_server_details();
$data = array();

if ( method_exists( parent::class, 'get_server_details' ) ) {
$data = parent::get_server_details();
} elseif ( method_exists( WC_Site_Tracking::class, 'get_server_details' ) ) {
// WC < 6.8
$data = WC_Site_Tracking::get_server_details(); // @phan-suppress-current-line PhanUndeclaredStaticMethod -- method is available in WC < 6.8
}

return array_merge(
$data,
array(
Expand All @@ -257,6 +266,22 @@ public static function get_server_details() {
);
}

/**
* Get the blog details.
*
* @param int $blog_id The blog ID.
* @return array The blog details.
*/
public static function get_blog_details( $blog_id ) {
if ( method_exists( parent::class, 'get_blog_details' ) ) {
return parent::get_blog_details( $blog_id );
} elseif ( method_exists( WC_Site_Tracking::class, 'get_blog_details' ) ) {
// WC < 6.8
return WC_Site_Tracking::get_blog_details( $blog_id ); // @phan-suppress-current-line PhanUndeclaredStaticMethod -- method is available in WC < 6.8
}
return array();
}

/**
* Get the session details as an array
*
Expand Down
Loading