From 7872b3555fc0ab785321f0b821acd4018b8fa8aa Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 19 Apr 2023 07:01:42 +0000 Subject: [PATCH 1/5] Empty commit for release pull request From 41e225e867dccdea2e1feef3bbb192b69e388349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Wed, 19 Apr 2023 09:07:31 +0200 Subject: [PATCH 2/5] Add 10.0.2 changelog --- readme.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.txt b/readme.txt index a75d64fa69b..66c7b6cfc09 100644 --- a/readme.txt +++ b/readme.txt @@ -80,6 +80,12 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ == Changelog == += 10.0.2 - 2023-04-19 = + +#### Bug Fixes + +- Fix infinite loop with the registration of Single Product Block (and inner blocks) breaking WP Post and Page editors in WP 6.1. ([9090](https://github.com/woocommerce/woocommerce-blocks/pull/9090)) + = 10.0.1 - 2023-04-18 = #### Bug Fixes From 732ffbbb8812855234eb667a57965453854c6f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Wed, 19 Apr 2023 09:08:19 +0200 Subject: [PATCH 3/5] Update versions to 10.0.2 --- composer.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 2 +- src/Package.php | 2 +- woocommerce-gutenberg-products-block.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index e912f0f7235..b8626e31f79 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "WooCommerce blocks for the Gutenberg editor.", "homepage": "https://woocommerce.com/", "type": "wordpress-plugin", - "version": "10.0.1", + "version": "10.0.2", "keywords": [ "gutenberg", "woocommerce", diff --git a/package-lock.json b/package-lock.json index 78f85c8ac2d..ed7715aa2b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@woocommerce/block-library", - "version": "10.0.1", + "version": "10.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@woocommerce/block-library", - "version": "10.0.1", + "version": "10.0.2", "hasInstallScript": true, "license": "GPL-3.0+", "dependencies": { diff --git a/package.json b/package.json index 1265b698480..311531b163f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@woocommerce/block-library", "title": "WooCommerce Blocks", "author": "Automattic", - "version": "10.0.1", + "version": "10.0.2", "description": "WooCommerce blocks for the Gutenberg editor.", "homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/", "keywords": [ diff --git a/readme.txt b/readme.txt index 66c7b6cfc09..a24a7ceefa5 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks Requires at least: 6.1 Tested up to: 6.2 Requires PHP: 7.3 -Stable tag: 10.0.1 +Stable tag: 10.0.2 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html diff --git a/src/Package.php b/src/Package.php index 3498450952c..68e062cf507 100644 --- a/src/Package.php +++ b/src/Package.php @@ -109,7 +109,7 @@ public static function container( $reset = false ) { NewPackage::class, function ( $container ) { // leave for automated version bumping. - $version = '10.0.1'; + $version = '10.0.2'; return new NewPackage( $version, dirname( __DIR__ ), diff --git a/woocommerce-gutenberg-products-block.php b/woocommerce-gutenberg-products-block.php index eb16d36f6c3..51af3701a42 100644 --- a/woocommerce-gutenberg-products-block.php +++ b/woocommerce-gutenberg-products-block.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce Blocks * Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block * Description: WooCommerce blocks for the Gutenberg editor. - * Version: 10.0.1 + * Version: 10.0.2 * Author: Automattic * Author URI: https://woocommerce.com * Text Domain: woo-gutenberg-products-block From 316ae4013531dbb7d482f4fa52ffa3dcccf51c8c Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Wed, 19 Apr 2023 03:08:40 -0400 Subject: [PATCH 4/5] Fix broken post/page editor screens in WordPress versions earlier than 6.2 (#9090) * Fix infinite loop (range error) on subscribe callback. * Replace getEditedPostContext with getEditedPostId to retrieve the templateId from the Site Editor for 6.1.1 compatibility --------- Co-authored-by: tjcafferkey --- .../register-block-single-product-template.ts | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/assets/js/atomic/utils/register-block-single-product-template.ts b/assets/js/atomic/utils/register-block-single-product-template.ts index 8b7e492f751..9d4df9ba2e4 100644 --- a/assets/js/atomic/utils/register-block-single-product-template.ts +++ b/assets/js/atomic/utils/register-block-single-product-template.ts @@ -13,6 +13,13 @@ import { } from '@wordpress/blocks'; import { subscribe, select } from '@wordpress/data'; +// Creating a local cache to prevent multiple registration tries. +const blocksRegistered = new Set(); + +function parseTemplateId( templateId: string | undefined ) { + return templateId?.split( '//' )[ 1 ]; +} + export const registerBlockSingleProductTemplate = ( { blockName, blockMetadata, @@ -31,9 +38,7 @@ export const registerBlockSingleProductTemplate = ( { subscribe( () => { const previousTemplateId = currentTemplateId; const store = select( 'core/edit-site' ); - currentTemplateId = store?.getEditedPostContext< { - templateSlug?: string; - } >()?.templateSlug; + currentTemplateId = parseTemplateId( store?.getEditedPostId() ); const hasChangedTemplate = previousTemplateId !== currentTemplateId; const hasTemplateId = Boolean( currentTemplateId ); @@ -86,16 +91,21 @@ export const registerBlockSingleProductTemplate = ( { }, 'core/edit-site' ); subscribe( () => { - const isBlockRegistered = Boolean( getBlockType( blockName ) ); - const editPostStoreExists = Boolean( select( 'core/edit-post' ) ); - - if ( ! isBlockRegistered && editPostStoreExists ) { + const isBlockRegistered = Boolean( variationName ) + ? blocksRegistered.has( variationName ) + : blocksRegistered.has( blockName ); + // This subscribe callback could be invoked with the core/blocks store + // which would cause infinite registration loops because of the `registerBlockType` call. + // This local cache helps prevent that. + if ( ! isBlockRegistered ) { if ( isVariationBlock ) { + blocksRegistered.add( variationName ); registerBlockVariation( blockName, blockSettings as BlockVariation< BlockAttributes > ); } else { + blocksRegistered.add( blockName ); // @ts-expect-error: `registerBlockType` is typed in WordPress core registerBlockType( blockMetadata, blockSettings ); } From d64f96d7fc99173a20715e0269feb561b7685178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Wed, 19 Apr 2023 09:24:01 +0200 Subject: [PATCH 5/5] Add 10.0.2 testing steps --- docs/internal-developers/testing/releases/1002.md | 12 ++++++++++++ docs/internal-developers/testing/releases/README.md | 1 + 2 files changed, 13 insertions(+) create mode 100644 docs/internal-developers/testing/releases/1002.md diff --git a/docs/internal-developers/testing/releases/1002.md b/docs/internal-developers/testing/releases/1002.md new file mode 100644 index 00000000000..dae40cf3e34 --- /dev/null +++ b/docs/internal-developers/testing/releases/1002.md @@ -0,0 +1,12 @@ +# Testing notes and ZIP for release 10.0.2 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/11269797/woocommerce-gutenberg-products-block.zip) + +## WooCommerce Core + +### Fix broken post/page editor screens in WordPress versions earlier than 6.2. [(9090)](https://github.com/woocommerce/woocommerce-blocks/pull/9090) + +1. Make sure your environment is WordPress 6.1.1 +2. Ensure the Post, Page and Site editors load without issues. +3. Go to Appearance > Editor > Templates > Single Product and add the Product Image Gallery block somewhere on the page. +4. Without reloading the page, edit the Single template (or any other template unrelated to WooCommerce). Verify you can't add the Product Image Gallery block. diff --git a/docs/internal-developers/testing/releases/README.md b/docs/internal-developers/testing/releases/README.md index 58c906f3131..246ca9c8b53 100644 --- a/docs/internal-developers/testing/releases/README.md +++ b/docs/internal-developers/testing/releases/README.md @@ -138,6 +138,7 @@ Every release includes specific testing instructions for new features and bug fi - [9.9.0](./990.md) - [10.0.0](./1000.md) - [10.0.1](./1001.md) + - [10.0.2](./1002.md)