From 79516e4d54b3452245bab678f8304401a775f353 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:12:16 +0530 Subject: [PATCH] Release: 10.8.1 (#10485) * Empty commit for release pull request * classicBlock: add defensive type handling (#10475) * Update check for active cart template and migration routine (#10462) * Update cart/checkout endpoints * Remove updating option on every page load * Check placeholder page vs current page * Check placeholder page vs current page * Switch from Rest to PHP for migrating templates * Existing page used for migration must contain post-content to be suitable --------- Co-authored-by: Mike Jolley * Version bumping & documentation for release 10.8.1 The primary changes include: 1. **Version Bumping**: Updated the version from 10.8.0 to 10.8.1 in several files including `composer.json`, `package-lock.json`, `package.json`, `readme.txt`, `src/Package.php`, and `woocommerce-gutenberg-products-block.php`. 2. **Documentation**: - Added a new testing notes file for release 10.8.1 (`docs/internal-developers/testing/releases/1081.md`). This file provides testing procedures for two bug fixes introduced in this release. 3. **Changelog**: Updated the `readme.txt` to include the bug fixes in the 10.8.1 changelog section. This release focuses on enhancing stability and user experience by addressing critical bugs. * Update readme file * Add zip file for testing --------- Co-authored-by: github-actions Co-authored-by: Luigi Teschio Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com> Co-authored-by: Mike Jolley Co-authored-by: Manish Menaria --- .../register-block-single-product-template.ts | 13 +++++-- assets/js/blocks/classic-template/index.tsx | 10 +++++- composer.json | 2 +- .../testing/releases/1081.md | 23 +++++++++++++ .../testing/releases/README.md | 1 + package-lock.json | 4 +-- package.json | 2 +- readme.txt | 9 ++++- src/BlockTemplatesController.php | 34 ++++++++++++++----- src/Package.php | 2 +- src/Templates/CartTemplate.php | 3 +- src/Templates/CheckoutTemplate.php | 3 +- woocommerce-gutenberg-products-block.php | 2 +- 13 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 docs/internal-developers/testing/releases/1081.md 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 d1e853acbe9..5d7e1ab020f 100644 --- a/assets/js/atomic/utils/register-block-single-product-template.ts +++ b/assets/js/atomic/utils/register-block-single-product-template.ts @@ -1,6 +1,7 @@ /** * External dependencies */ +import { isNumber } from '@woocommerce/types'; import { BlockAttributes, BlockConfiguration, @@ -16,8 +17,10 @@ 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 ]; +function parseTemplateId( templateId: string | number | undefined ) { + // With GB 16.3.0 the return type can be a number: https://github.com/WordPress/gutenberg/issues/53230 + const parsedTemplateId = isNumber( templateId ) ? undefined : templateId; + return parsedTemplateId?.split( '//' )[ 1 ]; } export const registerBlockSingleProductTemplate = ( { @@ -40,7 +43,11 @@ export const registerBlockSingleProductTemplate = ( { subscribe( () => { const previousTemplateId = currentTemplateId; const store = select( 'core/edit-site' ); - currentTemplateId = parseTemplateId( store?.getEditedPostId() ); + + // With GB 16.3.0 the return type can be a number: https://github.com/WordPress/gutenberg/issues/53230 + currentTemplateId = parseTemplateId( + store?.getEditedPostId() as string | number | undefined + ); const hasChangedTemplate = previousTemplateId !== currentTemplateId; const hasTemplateId = Boolean( currentTemplateId ); diff --git a/assets/js/blocks/classic-template/index.tsx b/assets/js/blocks/classic-template/index.tsx index 9d69c00c2b3..7f89427e0a0 100644 --- a/assets/js/blocks/classic-template/index.tsx +++ b/assets/js/blocks/classic-template/index.tsx @@ -31,6 +31,7 @@ import { store as noticesStore } from '@wordpress/notices'; import { useEntityRecord } from '@wordpress/core-data'; import { debounce } from '@woocommerce/base-utils'; import { woo } from '@woocommerce/icons'; +import { isNumber } from '@woocommerce/types'; /** * Internal dependencies @@ -417,7 +418,14 @@ let currentTemplateId: string | undefined; subscribe( () => { const previousTemplateId = currentTemplateId; const store = select( 'core/edit-site' ); - currentTemplateId = store?.getEditedPostId() as string | undefined; + // With GB 16.3.0 the return type can be a number: https://github.com/WordPress/gutenberg/issues/53230 + const editedPostId = store?.getEditedPostId() as + | string + | number + | undefined; + + currentTemplateId = isNumber( editedPostId ) ? undefined : editedPostId; + const parsedTemplate = currentTemplateId?.split( '//' )[ 1 ]; if ( parsedTemplate === null || parsedTemplate === undefined ) { diff --git a/composer.json b/composer.json index 3d807d55288..fcd15414076 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.8.0", + "version": "10.8.1", "keywords": [ "gutenberg", "woocommerce", diff --git a/docs/internal-developers/testing/releases/1081.md b/docs/internal-developers/testing/releases/1081.md new file mode 100644 index 00000000000..ea9a9557080 --- /dev/null +++ b/docs/internal-developers/testing/releases/1081.md @@ -0,0 +1,23 @@ +# Testing notes and ZIP for release 10.8.1 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/12274527/woocommerce-gutenberg-products-block.zip) + +## WooCommerce Core + +### Classic Template block registration: add defensive type handling [#10475](https://github.com/woocommerce/woocommerce-blocks/pull/10475) + +1. Ensure that you have installed Gutenberg 16.3.0. +2. Open the Site Editor. +3. Click on the navigation. +4. Click on the pencil (to edit button). +5. Ensure that the Site Editor doesn't crash + +| Before | After | +|--------|--------| +|