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

Release: 10.0.2 #9093

Merged
merged 5 commits into from
Apr 19, 2023
Merged
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
24 changes: 17 additions & 7 deletions assets/js/atomic/utils/register-block-single-product-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 );

Expand Down Expand Up @@ -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 );
}
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.0.1",
"version": "10.0.2",
"keywords": [
"gutenberg",
"woocommerce",
Expand Down
12 changes: 12 additions & 0 deletions docs/internal-developers/testing/releases/1002.md
Original file line number Diff line number Diff line change
@@ -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.
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 @@ -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)


<!-- 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.0.1",
"version": "10.0.2",
"description": "WooCommerce blocks for the Gutenberg editor.",
"homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/",
"keywords": [
Expand Down
8 changes: 7 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.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

Expand Down Expand Up @@ -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
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.0.1';
$version = '10.0.2';
return new NewPackage(
$version,
dirname( __DIR__ ),
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-gutenberg-products-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down