Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Release: 10.6.1 (#10229)
Browse files Browse the repository at this point in the history
* Empty commit for release pull request

* Product Filters > Fix Performance issue and Fatal error on stores with a high volume of products (#10198)

* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.

* Keep support for Product Collection block

* Stop reading Product IDs from asset store in filter blocks (#10195)

* Remove queries that fetch all products for manipulating the results returned by the Store API for certain use-cases.

* Remove the code that's supposed to read product ids for filter context and logic around that in useCollectionData

* Fix incorrect merge

---------

Co-authored-by: Patricia Hillebrandt <[email protected]>

* Add testing instructions for 10.6.1

* Fix margin issue with the Proceed to checkout button on the site editor (#10182)

* Fix margin issue with the Proceed to checkout button on the site editor

* Remove unecessary selector

* Merge pull request from GHSA-gxfx-93xq-pr6p

* Add cors check

* refactor logic

* Refactor add_cors_headers to allow null and allowed hosts

* Move remove_filter inline

* Revert unrelated code style changes

* Add explainer to docblock

* Remove access for null origin

* Move CORS handling to auth class so it applies API wide

* Move only Authentication to priority 11

* Handle preflight requests so cart-tokens work

---------

Co-authored-by: Mike Jolley <[email protected]>

* Add changelog to readme

* Bump versions, readme, changelog, and testing notes

* Add testing zip

* fix migration (#10205)

* New testing zip

* Don't send headers early in Store API (#10241)

* Replace sanitization functions to enforce string values (#10242)

* New testing zip

* Update changelog

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Patricia Hillebrandt <[email protected]>
Co-authored-by: Karol Manijak <[email protected]>
Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Alex Florisca <[email protected]>
Co-authored-by: Seghir Nadir <[email protected]>
Co-authored-by: Mike Jolley <[email protected]>
Co-authored-by: Luigi Teschio <[email protected]>
  • Loading branch information
9 people authored Jul 18, 2023
1 parent 1c6e2eb commit 33ec179
Show file tree
Hide file tree
Showing 21 changed files with 240 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { useState, useEffect, useMemo } from '@wordpress/element';
import { useDebounce } from 'use-debounce';
import { isEmpty, objectHasProp } from '@woocommerce/types';
import { objectHasProp } from '@woocommerce/types';
import { sort } from 'fast-sort';
import { useShallowEqual } from '@woocommerce/base-hooks';

Expand Down Expand Up @@ -46,7 +46,6 @@ interface UseCollectionDataProps {
queryStock?: boolean;
queryRating?: boolean;
queryState: Record< string, unknown >;
productIds?: number[];
isEditor?: boolean;
}

Expand All @@ -56,7 +55,6 @@ export const useCollectionData = ( {
queryStock,
queryRating,
queryState,
productIds,
isEditor = false,
}: UseCollectionDataProps ) => {
let context = useQueryStateContext();
Expand Down Expand Up @@ -166,7 +164,6 @@ export const useCollectionData = ( {
per_page: undefined,
orderby: undefined,
order: undefined,
...( ! isEmpty( productIds ) && { include: productIds } ),
...collectionDataQueryVars,
},
shouldSelect: debouncedShouldSelect,
Expand Down
5 changes: 0 additions & 5 deletions assets/js/blocks/attribute-filter/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ const AttributeFilterBlock = ( {
isString
);

const productIds = isEditor
? []
: getSettingWithCoercion( 'product_ids', [], Array.isArray );

const [ hasSetFilterDefaultsFromUrl, setHasSetFilterDefaultsFromUrl ] =
useState( false );

Expand Down Expand Up @@ -144,7 +140,6 @@ const AttributeFilterBlock = ( {
queryState: {
...queryState,
},
productIds,
isEditor,
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
}
}

.wp-block-woocommerce-proceed-to-checkout-block {
margin-bottom: 28px;
margin-top: 28px;
}

.wp-block-woocommerce-checkout-express-payment-block-placeholder {
* {
pointer-events: all; // Overrides parent disabled component in editor context
Expand Down
5 changes: 0 additions & 5 deletions assets/js/blocks/price-filter/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ const PriceFilterBlock = ( {
isBoolean
);

const productIds = isEditor
? []
: getSettingWithCoercion( 'product_ids', [], Array.isArray );

const [ hasSetFilterDefaultsFromUrl, setHasSetFilterDefaultsFromUrl ] =
useState( false );

Expand All @@ -112,7 +108,6 @@ const PriceFilterBlock = ( {
const { results, isLoading } = useCollectionData( {
queryPrices: true,
queryState,
productIds,
isEditor,
} );

Expand Down
5 changes: 0 additions & 5 deletions assets/js/blocks/stock-filter/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ const StockStatusFilterBlock = ( {
{}
);

const productIds = isEditor
? []
: getSettingWithCoercion( 'product_ids', [], Array.isArray );

const STOCK_STATUS_OPTIONS: { current: Current } = useRef(
getSetting( 'hideOutOfStockItems', false )
? otherStockStatusOptions
Expand Down Expand Up @@ -111,7 +107,6 @@ const StockStatusFilterBlock = ( {
useCollectionData( {
queryStock: true,
queryState,
productIds,
isEditor,
} );

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "WooCommerce blocks for the Gutenberg editor.",
"homepage": "https://woocommerce.com/",
"type": "wordpress-plugin",
"version": "10.6.0",
"version": "10.6.1",
"keywords": [
"gutenberg",
"woocommerce",
Expand Down
46 changes: 46 additions & 0 deletions docs/internal-developers/testing/releases/1061.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Testing notes and ZIP for release 10.6.1

Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/12071467/woocommerce-gutenberg-products-block.zip)


## WooCommerce Core

### Product Filters > Fix Performance issue and Fatal error on stores with a high volume of products [#10198](https://github.com/woocommerce/woocommerce-blocks/pull/10198)

1. Make sure you have products in your store with attributes and stock status (You can do so by simply importing the sample products from the core of Woo).
2. Create a new post.
3. Insert the Products (Beta) block.
4. Insert the Filter by Attribute, Filter by Stock and Filter by Price
5. Make sure all filters have the "Display product count" setting enabled (it is disabled by default).

<img width="309" alt="Screenshot 2023-07-13 at 20 09 31" src="https://github.com/woocommerce/woocommerce-blocks/assets/15730971/749275ca-94f9-4990-99f2-f302aaa4aab0">

6. Save the post and go to the front-end
7. Make sure you can use all filters as expected and without any problems/errors: the product counts should match the number of existing products in the store with the filtered criteria, not just what is displayed on the page.
8. Repeat all steps from 2 to 7, but using the Products Collection block instead of Products (beta). Make sure all filters work as expected.

### Stop reading Product IDs from asset store in filter blocks [#10195](https://github.com/woocommerce/woocommerce-blocks/pull/10195)

1. Go to Editor
2. Add Filters pattern
3. Add Products (Beta) block
4. Save and go to frontend
5. Play around with filters

Expected: Make sure you can use all filters as expected and without any problems/errors: the product counts should match the number of existing products in the store with the filtered criteria, not just what is displayed on the page.

### Fix margin issue with the Proceed to checkout button on the site editor [#10182](https://github.com/woocommerce/woocommerce-blocks/pull/10182)

1. Install and activate a block theme (e.g. Twenty Twenty Three)
2. Edit the Cart page
3. Check the Proceed to Checkout button has some padding around it
4. Switch to a non block theme page (e.g. Storefront)
5. Check that the Proceed to Checkout button has the same padding around it

| Before | After |
|--------------------------------------------------------------------------------------------------------------------------------------------- |--------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Screenshot 2023-07-12 at 09 59 20](https://github.com/woocommerce/woocommerce-blocks/assets/3966773/6130d5bc-9e9b-487d-a2a3-9d2a46ced417) | ![Screenshot 2023-07-12 at 12 57 32](https://github.com/woocommerce/woocommerce-blocks/assets/3966773/48681cef-6517-4c52-af71-7d78d0dbd02e) |




1 change: 1 addition & 0 deletions docs/internal-developers/testing/releases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Every release includes specific testing instructions for new features and bug fi
- [10.4.5](./1045.md)
- [10.5.0](./1050.md)
- [10.6.0](./1060.md)
- [10.6.1](./1061.md)


<!-- FEEDBACK -->
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@woocommerce/block-library",
"title": "WooCommerce Blocks",
"author": "Automattic",
"version": "10.6.0",
"version": "10.6.1",
"description": "WooCommerce blocks for the Gutenberg editor.",
"homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/",
"keywords": [
Expand Down
13 changes: 12 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks
Requires at least: 6.2
Tested up to: 6.2
Requires PHP: 7.3
Stable tag: 10.6.0
Stable tag: 10.6.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -81,6 +81,17 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/

== Changelog ==

= 10.6.1 - 2021-07-17 =

#### Bug Fixes

- Improve performance and fix memory exhaustion errors that could be triggered for stores with a high volume of products using the Products (Beta) or Products Collection blocks. ([#10198](https://github.com/woocommerce/woocommerce-blocks/pull/10198))
- Fix a visual bug with margins around the Proceed to Checkout button on the Cart block. ([#10182](https://github.com/woocommerce/woocommerce-blocks/pull/10182))
- Fixed formatting for addresses sent to the Store API. ([#10242](https://github.com/woocommerce/woocommerce-blocks/pull/10242))

#### Security
- Update CORS handling in Store API

= 10.6.0 - 2023-07-07 =

#### Enhancements
Expand Down
13 changes: 0 additions & 13 deletions src/BlockTypes/ProductCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,6 @@ public function add_support_for_filter_blocks( $pre_render, $parsed_block ) {
* which is a server-side rendered (SSR) block, retrieves the products that match the filters.
*/
$this->asset_data_registry->add( 'is_rendering_php_template', true, true );

$frontend_query = $this->get_final_frontend_query( $parsed_block['attrs']['query'], null, true );
// Override the query to get all products.
$fields_to_override = [
'posts_per_page' => -1,
'paged' => null,
];
$new_array = array_merge( $frontend_query, $fields_to_override );

$products = new \WP_Query( $new_array );
$product_ids = wp_list_pluck( $products->posts, 'ID' );
// Add the product ids to the asset data registry, so that filter blocks can use it.
$this->asset_data_registry->add( 'product_ids', $product_ids, true );
}

/**
Expand Down
28 changes: 0 additions & 28 deletions src/BlockTypes/ProductQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public function update_query( $pre_render, $parsed_block ) {
// Set this so that our product filters can detect if it's a PHP template.
$this->asset_data_registry->add( 'has_filterable_products', true, true );
$this->asset_data_registry->add( 'is_rendering_php_template', true, true );
$this->asset_data_registry->add( 'product_ids', $this->get_products_ids_by_attributes( $parsed_block ), true );
add_filter(
'query_loop_block_query_vars',
array( $this, 'build_query' ),
Expand Down Expand Up @@ -224,33 +223,6 @@ public function build_query( $query ) {
return $this->filter_query_to_only_include_ids( $merged_query, $handpicked_products );
}

/**
* Return the product ids based on the attributes and global query.
* This is used to allow the filter blocks to render data that matches with variations. More details here: https://github.com/woocommerce/woocommerce-blocks/issues/7245
*
* @param array $parsed_block The block being rendered.
* @return array
*/
private function get_products_ids_by_attributes( $parsed_block ) {
$query = $this->merge_queries(
array(
'post_type' => 'product',
'post__in' => array(),
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(),
'tax_query' => array(),
),
$this->get_queries_by_custom_attributes( $parsed_block ),
$this->get_global_query( $parsed_block )
);

$products = new \WP_Query( $query );
$post_ids = wp_list_pluck( $products->posts, 'ID' );

return $post_ids;
}

/**
* Merge in the first parameter the keys "post_in", "meta_query" and "tax_query" of the second parameter.
*
Expand Down
9 changes: 4 additions & 5 deletions src/Domain/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ protected function init() {
$this->register_dependencies();
$this->register_payment_methods();

if ( is_admin() ) {
if ( $this->package->get_version() !== $this->package->get_version_stored_on_db() ) {
$this->migration->run_migrations();
$this->package->set_version_stored_on_db();
}
// This is just a temporary solution to make sure the migrations are run. We have to refactor this. More details: https://github.com/woocommerce/woocommerce-blocks/issues/10196.
if ( $this->package->get_version() !== $this->package->get_version_stored_on_db() ) {
$this->migration->run_migrations();
$this->package->set_version_stored_on_db();
}

add_action(
Expand Down
2 changes: 1 addition & 1 deletion src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function container( $reset = false ) {
NewPackage::class,
function ( $container ) {
// leave for automated version bumping.
$version = '10.6.0';
$version = '10.6.1';
return new NewPackage(
$version,
dirname( __DIR__ ),
Expand Down
Loading

0 comments on commit 33ec179

Please sign in to comment.