Release: 10.8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/10517)
* Revert woocommerce/woocommerce-blocks#10509 (https://github.com/woocommerce/woocommerce-blocks/pull/10513)
* Revert "Revert "Performance: Cache script data in a transient for production builds" (https://github.com/woocommerce/woocommerce-blocks/pull/10509)"
This reverts commit 5bcf8657ee
.
* keep WP 6.2.2 as env to run E2E tests
* Empty commit for release pull request
* update changelog and testing instructions
* bump version to 10.8.2
* update zip link
---------
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
1a80d70250
commit
10620a7517
|
@ -3,7 +3,7 @@
|
|||
"description": "WooCommerce blocks for the Gutenberg editor.",
|
||||
"homepage": "https://woocommerce.com/",
|
||||
"type": "wordpress-plugin",
|
||||
"version": "10.8.1",
|
||||
"version": "10.8.2",
|
||||
"keywords": [
|
||||
"gutenberg",
|
||||
"woocommerce",
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# Testing notes and ZIP for release 10.8.2
|
||||
|
||||
Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/12301273/woocommerce-gutenberg-products-block.zip)
|
||||
|
||||
## WooCommerce Core
|
||||
|
||||
### Invalidate script data cache when site URL, scheme, or plugin name changes [#10278](https://github.com/woocommerce/woocommerce-blocks/pull/10278)
|
||||
|
||||
1. Load up your site, ensuring WooCommerce Blocks is active. Visit a page with the Cart or Checkout block on it.
|
||||
2. Disable and delete the WooCommerce Blocks plugin from your site.
|
||||
3. Load up the page from Step 1 and ensure it loads correctly.
|
|
@ -163,6 +163,7 @@ Every release includes specific testing instructions for new features and bug fi
|
|||
- [10.7.0](./1070.md)
|
||||
- [10.8.0](./1080.md)
|
||||
- [10.8.1](./1081.md)
|
||||
- [10.8.2](./1082.md)
|
||||
|
||||
|
||||
<!-- FEEDBACK -->
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@woocommerce/block-library",
|
||||
"version": "10.8.1",
|
||||
"version": "10.8.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@woocommerce/block-library",
|
||||
"version": "10.8.1",
|
||||
"version": "10.8.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "GPL-3.0+",
|
||||
"dependencies": {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "@woocommerce/block-library",
|
||||
"title": "WooCommerce Blocks",
|
||||
"author": "Automattic",
|
||||
"version": "10.8.1",
|
||||
"version": "10.8.2",
|
||||
"description": "WooCommerce blocks for the Gutenberg editor.",
|
||||
"homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/",
|
||||
"keywords": [
|
||||
|
|
|
@ -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.8.1
|
||||
Stable tag: 10.8.2
|
||||
License: GPLv3
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
|
@ -81,6 +81,12 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 10.8.2 - 2023-08-09 =
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
- Ensure cached script data is refreshed following a site URL change, version change, or when switching between the WooCommerce Blocks feature plugin and WooCommerce Core.
|
||||
|
||||
= 10.8.1 - 2023-08-07 =
|
||||
|
||||
#### Bug Fixes
|
||||
|
|
|
@ -32,6 +32,20 @@ class Api {
|
|||
*/
|
||||
private $script_data = null;
|
||||
|
||||
/**
|
||||
* Stores the hash for the script data, made up of the site url, plugin version and package path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $script_data_hash;
|
||||
|
||||
/**
|
||||
* Stores the transient key used to cache the script data. This will change if the site is accessed via HTTPS or HTTP.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $script_data_transient_key = 'woocommerce_blocks_asset_api_script_data';
|
||||
|
||||
/**
|
||||
* Reference to the Package instance
|
||||
*
|
||||
|
@ -47,6 +61,15 @@ class Api {
|
|||
public function __construct( Package $package ) {
|
||||
$this->package = $package;
|
||||
$this->disable_cache = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || ! $this->package->feature()->is_production_environment();
|
||||
|
||||
// If the site is accessed via HTTPS, change the transient key. This is to prevent the script URLs being cached
|
||||
// with the first scheme they are accessed on after cache expiry.
|
||||
if ( is_ssl() ) {
|
||||
$this->script_data_transient_key .= '_ssl';
|
||||
}
|
||||
if ( ! $this->disable_cache ) {
|
||||
$this->script_data_hash = $this->get_script_data_hash();
|
||||
}
|
||||
add_action( 'shutdown', array( $this, 'update_script_data_cache' ), 20 );
|
||||
}
|
||||
|
||||
|
@ -92,6 +115,17 @@ class Api {
|
|||
return $path_to_metadata_from_plugin_root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a hash containing the site url, plugin version and package path.
|
||||
*
|
||||
* Moving the plugin, changing the version, or changing the site url will result in a new hash and the cache will be invalidated.
|
||||
*
|
||||
* @return string The generated hash.
|
||||
*/
|
||||
private function get_script_data_hash() {
|
||||
return md5( get_option( 'siteurl', '' ) . $this->package->get_version() . $this->package->get_path() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize and load cached script data from the transient cache.
|
||||
*
|
||||
|
@ -102,9 +136,17 @@ class Api {
|
|||
return [];
|
||||
}
|
||||
|
||||
$transient_value = json_decode( (string) get_transient( 'woocommerce_blocks_asset_api_script_data' ), true );
|
||||
$transient_value = json_decode( (string) get_transient( $this->script_data_transient_key ), true );
|
||||
|
||||
if ( empty( $transient_value ) || empty( $transient_value['script_data'] ) || empty( $transient_value['version'] ) || $transient_value['version'] !== $this->package->get_version() ) {
|
||||
if (
|
||||
json_last_error() !== JSON_ERROR_NONE ||
|
||||
empty( $transient_value ) ||
|
||||
empty( $transient_value['script_data'] ) ||
|
||||
empty( $transient_value['version'] ) ||
|
||||
$transient_value['version'] !== $this->package->get_version() ||
|
||||
empty( $transient_value['hash'] ) ||
|
||||
$transient_value['hash'] !== $this->script_data_hash
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -119,11 +161,12 @@ class Api {
|
|||
return;
|
||||
}
|
||||
set_transient(
|
||||
'woocommerce_blocks_asset_api_script_data',
|
||||
$this->script_data_transient_key,
|
||||
wp_json_encode(
|
||||
array(
|
||||
'script_data' => $this->script_data,
|
||||
'version' => $this->package->get_version(),
|
||||
'hash' => $this->script_data_hash,
|
||||
)
|
||||
),
|
||||
DAY_IN_SECONDS * 30
|
||||
|
|
|
@ -109,7 +109,7 @@ class Package {
|
|||
NewPackage::class,
|
||||
function ( $container ) {
|
||||
// leave for automated version bumping.
|
||||
$version = '10.8.1';
|
||||
$version = '10.8.2';
|
||||
return new NewPackage(
|
||||
$version,
|
||||
dirname( __DIR__ ),
|
||||
|
|
|
@ -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.8.1
|
||||
* Version: 10.8.2
|
||||
* Author: Automattic
|
||||
* Author URI: https://woocommerce.com
|
||||
* Text Domain: woo-gutenberg-products-block
|
||||
|
|
Loading…
Reference in New Issue