Plugin Updates

This commit is contained in:
Tony Volpe
2024-04-02 20:23:21 +00:00
parent 96800520e8
commit 94170ec2c4
1514 changed files with 133309 additions and 105985 deletions

View File

@@ -11,7 +11,6 @@ defined( 'ABSPATH' ) || exit;
use ActionScheduler;
use Automattic\Jetpack\Connection\Manager;
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Admin\PluginsHelper;
use Automattic\WooCommerce\Admin\PluginsInstallLoggers\AsynPluginsInstallLogger;
use WC_REST_Data_Controller;
@@ -125,30 +124,6 @@ class OnboardingPlugins extends WC_REST_Data_Controller {
),
)
);
/*
* This is a temporary solution to override /jetpack/v4/connection/data endpoint
* registered by Jetpack Connection when Jetpack is not installed.
*
* For more details, see https://github.com/woocommerce/woocommerce/issues/38979
*/
if ( Constants::get_constant( 'JETPACK__VERSION' ) === null && wp_is_mobile() ) {
register_rest_route(
'jetpack/v4',
'/connection/data',
array(
array(
'methods' => 'GET',
'permission_callback' => '__return_true',
'callback' => function() {
return new WP_REST_Response( null, 404 );
},
),
),
true
);
}
add_action( 'woocommerce_plugins_install_error', array( $this, 'log_plugins_install_error' ), 10, 4 );
add_action( 'woocommerce_plugins_install_api_error', array( $this, 'log_plugins_install_api_error' ), 10, 2 );
}

View File

@@ -365,7 +365,7 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
$import = self::import_sample_products_from_csv( $template_path );
if ( is_wp_error( $import ) || 0 === count( $import['imported'] ) ) {
if ( is_wp_error( $import ) || ! is_array( $import['imported'] ) || 0 === count( $import['imported'] ) ) {
return new \WP_Error(
'woocommerce_rest_product_creation_error',
/* translators: %s is template name */
@@ -740,6 +740,14 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
$lists = is_array( $task_list_ids ) && count( $task_list_ids ) > 0 ? TaskLists::get_lists_by_ids( $task_list_ids ) : TaskLists::get_lists();
// We have no use for hidden lists, it's expensive to compute individual tasks completion.
$lists = array_filter(
$lists,
function( $list ) {
return ! $list->is_hidden();
}
);
$json = array_map(
function( $list ) {
return $list->sort_tasks()->get_json();

View File

@@ -548,7 +548,7 @@ class Plugins extends \WC_REST_Data_Controller {
if ( ! class_exists( '\WooCommerce\Square\Handlers\Connection' ) ) {
return new \WP_Error( 'woocommerce_rest_helper_connect', __( 'There was an error connecting to Square.', 'woocommerce' ), 500 );
}
$has_cbd_industry = false;
if ( 'US' === WC()->countries->get_base_country() ) {
$profile = get_option( OnboardingProfile::DATA_OPTION, array() );
if ( ! empty( $profile['industry'] ) ) {

View File

@@ -162,7 +162,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
* Returns an array of ids of included categories, based on query arguments from the user.
*
* @param array $query_args Parameters supplied by the user.
* @return string
* @return array
*/
protected function get_included_categories_array( $query_args ) {
if ( isset( $query_args['category_includes'] ) && is_array( $query_args['category_includes'] ) && count( $query_args['category_includes'] ) > 0 ) {

View File

@@ -62,13 +62,20 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
);
}
// This method was already available as non-final, marking it as final now would make it backwards-incompatible.
// phpcs:disable WooCommerce.Functions.InternalInjectionMethod.MissingFinal
/**
* Set up all the hooks for maintaining and populating table data.
*
* @internal
*/
public static function init() {
add_action( 'woocommerce_analytics_delete_order_stats', array( __CLASS__, 'sync_on_order_delete' ), 5 );
}
// phpcs:enable WooCommerce.Functions.InternalInjectionMethod.MissingFinal
/**
* Returns an array of ids of included coupons, based on query arguments from the user.
*
@@ -339,6 +346,11 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
*/
public static function get_coupon_id( \WC_Order_Item_Coupon $coupon_item ) {
// First attempt to get coupon ID from order item data.
$coupon_info = $coupon_item->get_meta( 'coupon_info', true );
if ( $coupon_info ) {
return json_decode( $coupon_info, true )[0];
}
$coupon_data = $coupon_item->get_meta( 'coupon_data', true );
// Normal checkout orders should have this data.

View File

@@ -258,6 +258,7 @@ class Segmenter extends ReportsSegmenter {
return array();
}
$segments = null;
$product_segmenting_table = $wpdb->prefix . 'wc_order_product_lookup';
$unique_orders_table = '';
$segmenting_where = '';
@@ -279,7 +280,7 @@ class Segmenter extends ReportsSegmenter {
$segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );
} elseif ( 'variation' === $this->query_args['segmentby'] ) {
if ( ! isset( $this->query_args['product_includes'] ) || count( $this->query_args['product_includes'] ) !== 1 ) {
if ( ! isset( $this->query_args['product_includes'] ) || ! is_array( $this->query_args['product_includes'] ) || count( $this->query_args['product_includes'] ) !== 1 ) {
throw new ParameterException( 'wc_admin_reports_invalid_segmenting_variation', __( 'product_includes parameter need to specify exactly one product when segmenting by variation.', 'woocommerce' ) );
}

View File

@@ -374,7 +374,7 @@ class Segmenter extends ReportsSegmenter {
$segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );
} elseif ( 'variation' === $this->query_args['segmentby'] ) {
if ( ! isset( $this->query_args['product_includes'] ) || count( $this->query_args['product_includes'] ) !== 1 ) {
if ( ! isset( $this->query_args['product_includes'] ) || ! is_array( $this->query_args['product_includes'] ) || count( $this->query_args['product_includes'] ) !== 1 ) {
throw new ParameterException( 'wc_admin_reports_invalid_segmenting_variation', __( 'product_includes parameter need to specify exactly one product when segmenting by variation.', 'woocommerce' ) );
}

View File

@@ -165,7 +165,7 @@ class Segmenter extends ReportsSegmenter {
$segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );
} elseif ( 'variation' === $this->query_args['segmentby'] ) {
if ( ! isset( $this->query_args['product_includes'] ) || count( $this->query_args['product_includes'] ) !== 1 ) {
if ( ! isset( $this->query_args['product_includes'] ) || ! is_array( count( $this->query_args['product_includes'] ) ) || count( $this->query_args['product_includes'] ) !== 1 ) {
throw new ParameterException( 'wc_admin_reports_invalid_segmenting_variation', __( 'product_includes parameter need to specify exactly one product when segmenting by variation.', 'woocommerce' ) );
}

View File

@@ -368,6 +368,7 @@ class Segmenter {
if (
isset( $this->query_args['product_includes'] ) &&
is_array( $this->query_args['product_includes'] ) &&
count( $this->query_args['product_includes'] ) === 1
) {
$args['parent'] = $this->query_args['product_includes'][0];

View File

@@ -175,7 +175,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
$this->add_sql_query_params( $query_args );
$params = $this->get_limit_params( $query_args );
if ( isset( $query_args['taxes'] ) && ! empty( $query_args['taxes'] ) ) {
if ( isset( $query_args['taxes'] ) && is_array( $query_args['taxes'] ) && ! empty( $query_args['taxes'] ) ) {
$total_results = count( $query_args['taxes'] );
$total_pages = (int) ceil( $total_results / $params['per_page'] );

View File

@@ -77,6 +77,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
$order_tax_lookup_table = self::get_db_table_name();
if ( isset( $query_args['taxes'] ) && ! empty( $query_args['taxes'] ) ) {
$query_args['taxes'] = (array) $query_args['taxes'];
$tax_id_placeholders = implode( ',', array_fill( 0, count( $query_args['taxes'] ), '%d' ) );
/* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
$taxes_where_clause .= $wpdb->prepare( " AND {$order_tax_lookup_table}.tax_rate_id IN ({$tax_id_placeholders})", $query_args['taxes'] );
@@ -115,6 +116,7 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
FROM {$wpdb->prefix}woocommerce_tax_rates
";
if ( ! empty( $args['include'] ) ) {
$args['include'] = (array) $args['include'];
/* phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared */
$tax_placeholders = implode( ',', array_fill( 0, count( $args['include'] ), '%d' ) );
$query .= $wpdb->prepare( " WHERE tax_rate_id IN ({$tax_placeholders})", $args['include'] );

View File

@@ -586,6 +586,7 @@ class TimeInterval {
}
if (
! is_array( $value ) ||
2 !== count( $value ) ||
! is_numeric( $value[0] ) ||
! is_numeric( $value[1] )
@@ -618,6 +619,7 @@ class TimeInterval {
}
if (
! is_array( $value ) ||
2 !== count( $value ) ||
! rest_parse_date( $value[0] ) ||
! rest_parse_date( $value[1] )

View File

@@ -140,7 +140,7 @@ class Segmenter extends ReportsSegmenter {
* @param array $query_params SQL query parameter array.
* @param string $table_name Name of main SQL table for the data store (used as basis for JOINS).
*
* @return array
* @return array|null
* @throws \Automattic\WooCommerce\Admin\API\Reports\ParameterException In case of segmenting by variations, when no parent product is specified.
*/
protected function get_segments( $type, $query_params, $table_name ) {
@@ -148,7 +148,7 @@ class Segmenter extends ReportsSegmenter {
if ( ! isset( $this->query_args['segmentby'] ) || '' === $this->query_args['segmentby'] ) {
return array();
}
$segments = null;
$product_segmenting_table = $wpdb->prefix . 'wc_order_product_lookup';
$unique_orders_table = 'uniq_orders';
$segmenting_where = '';

View File

@@ -192,7 +192,7 @@ class Themes extends \WC_REST_Data_Controller {
* @return array
*/
public function get_collection_params() {
$params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
$params = array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ) );
$params['pluginzip'] = array(
'description' => __( 'A zip file of the theme to be uploaded.', 'woocommerce' ),
'type' => 'file',