From 1c6f33f6cb0f91d062fec5ce6e7c7b19e79a0618 Mon Sep 17 00:00:00 2001 From: louwie17 Date: Wed, 27 Mar 2024 05:06:16 -0300 Subject: [PATCH] Remove accidental count call within an is_array check (#45939) Remove accidental count call within an is_array check that always renders false --- .../woocommerce/changelog/fix-analytics_comparison_by_product | 4 ++++ .../src/Admin/API/Reports/Products/Stats/Segmenter.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/fix-analytics_comparison_by_product diff --git a/plugins/woocommerce/changelog/fix-analytics_comparison_by_product b/plugins/woocommerce/changelog/fix-analytics_comparison_by_product new file mode 100644 index 000000000000..53d175eeabf8 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-analytics_comparison_by_product @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Removed count from is_array check to fix Analytics comparison filter. diff --git a/plugins/woocommerce/src/Admin/API/Reports/Products/Stats/Segmenter.php b/plugins/woocommerce/src/Admin/API/Reports/Products/Stats/Segmenter.php index e1beca45eb54..16524cd9724c 100644 --- a/plugins/woocommerce/src/Admin/API/Reports/Products/Stats/Segmenter.php +++ b/plugins/woocommerce/src/Admin/API/Reports/Products/Stats/Segmenter.php @@ -165,7 +165,7 @@ protected function get_segments( $type, $query_params, $table_name ) { $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'] ) || ! is_array( count( $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' ) ); }