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

Commit

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

* Add readme and testing notes

* Bump versions to 11.5.1

* Fix Single Product Classic Template block not showing on the front-end (#11455)

In WordPress 6.4, it appears that the global `have_posts` is `false` in
the context of the full site editing single product template. This
breaks the Classic Template block.

In this commit, we are creating a custom query using the available id
instead of relying on the global query.

This might be a temporary workaround as we are waiting to see
if that's an issue that core is willing to fix, as it might affect
backwards-compatibility for other vendors.

(cherry picked from commit d9e8809)

* Update testing notes with new zip file

* Add protection against wrong params in get_block_template_fallback() (#11690)

* Add protection towards wrong params in get_block_template_fallback()

* Improve protection

* Update WC Blocks 11.5.1 changelog and testing steps with new fix

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Lucio Giannotta <[email protected]>
Co-authored-by: Albert Juhé Lluveras <[email protected]>
  • Loading branch information
4 people authored Nov 8, 2023
1 parent 851ce15 commit 721e6a7
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 12 deletions.
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": "11.5.0",
"version": "11.5.1",
"keywords": [
"gutenberg",
"woocommerce",
Expand Down
23 changes: 23 additions & 0 deletions docs/internal-developers/testing/releases/1151.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Testing notes and ZIP for release 11.5.1

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

## WooCommerce Core

### Bug Fixes

#### Fix Single Product Classic Template block not showing on the front-end. [11455](https://github.com/woocommerce/woocommerce-blocks/pull/11455)

1. Enable WordPress 6.4.
2. Enable a block theme.
3. Go to Site Editor → Single Product template.
4. Remove the blockified template and add the “Classic Template” block.
5. Save and check the front-end.
6. Check that the template is correctly rendered on the front-end.

#### Add protection against wrong params in get_block_template_fallback(). [11690](https://github.com/woocommerce/woocommerce-blocks/pull/11690)

1. Go to a Product Category page in the frontend (ie: `/product-category/clothing/accessories/`).
2. Verify it's displayed with the Product Catalog template.
3. Go to Appearance > Editor > Templates > Product Catalog and make some edits.
4. Go again to the Product Category page in the frontend and verify the changes are applied there as well.
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 @@ -186,3 +186,4 @@ Every release includes specific testing instructions for new features and bug fi
- [11.4.2](./1142.md)
- [11.4.3](./1143.md)
- [11.5.0](./1150.md)
- [11.5.1](./1151.md)
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": "11.5.0",
"version": "11.5.1",
"description": "WooCommerce blocks for the Gutenberg editor.",
"homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/",
"keywords": [
Expand Down
9 changes: 8 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.3
Tested up to: 6.3
Requires PHP: 7.4
Stable tag: 11.5.0
Stable tag: 11.5.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

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

== Changelog ==

= 11.5.1 - 2023-11-08 =

#### Bug Fixes

- WordPress 6.4: fixed a bug which would break sites using the Classic Template block for the Single Product template. ([11455](https://github.com/woocommerce/woocommerce-blocks/pull/11455))
- Fix an error that might appear when pre_get_block_template filter was called with wrong params. ([11690](https://github.com/woocommerce/woocommerce-blocks/pull/11690))

= 11.5.0 - 2023-11-06 =

#### Enhancements
Expand Down
18 changes: 15 additions & 3 deletions src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,22 @@ public function render_woocommerce_template_part( $attributes ) {
* @return object|null
*/
public function get_block_template_fallback( $template, $id, $template_type ) {
$template_name_parts = explode( '//', $id );
list( $theme, $slug ) = $template_name_parts;
// Add protection against invalid ids.
if ( ! is_string( $id ) || ! strstr( $id, '//' ) ) {
return null;
}
// Add protection against invalid template types.
if (
'wp_template' !== $template_type &&
'wp_template_part' !== $template_type
) {
return null;
}
$template_name_parts = explode( '//', $id );
$theme = $template_name_parts[0] ?? '';
$slug = $template_name_parts[1] ?? '';

if ( ! BlockTemplateUtils::template_is_eligible_for_product_archive_fallback( $slug ) ) {
if ( empty( $theme ) || empty( $slug ) || ! BlockTemplateUtils::template_is_eligible_for_product_archive_fallback( $slug ) ) {
return null;
}

Expand Down
11 changes: 9 additions & 2 deletions src/BlockTypes/ClassicTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,16 @@ protected function render_single_product() {
*/
do_action( 'woocommerce_before_main_content' );

while ( have_posts() ) :
$product_query = new \WP_Query(
array(
'post_type' => 'product',
'p' => get_the_ID(),
)
);

while ( $product_query->have_posts() ) :

the_post();
$product_query->the_post();
wc_get_template_part( 'content', 'single-product' );

endwhile;
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 = '11.5.0';
$version = '11.5.1';
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: 11.5.0
* Version: 11.5.1
* Author: Automattic
* Author URI: https://woocommerce.com
* Text Domain: woo-gutenberg-products-block
Expand Down

0 comments on commit 721e6a7

Please sign in to comment.