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

Commit

Permalink
Release: 10.6.5 (#10510)
Browse files Browse the repository at this point in the history
* Revert "Performance: Cache script data in a transient for production builds" (#10509)

* Revert "Performance: Cache script data in a transient for production builds (#9120)"

This reverts commit 6b9955d.

* fix WordPress version

* fix version

* update version to 10.6.5

* update changelog and testing instructions

* update zip link

* fix changelog

---------

Co-authored-by: Luigi Teschio <[email protected]>
  • Loading branch information
github-actions[bot] and gigitux authored Aug 9, 2023
1 parent cd04eac commit 7ca3489
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"core": null,
"core": "WordPress/WordPress#6.2.2",
"plugins": [
"https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip",
"https://github.com/WP-API/Basic-Auth/archive/master.zip",
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.6.4",
"version": "10.6.5",
"keywords": [
"gutenberg",
"woocommerce",
Expand Down
10 changes: 10 additions & 0 deletions docs/internal-developers/testing/releases/1065.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Testing notes and ZIP for release 10.6.5

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

## WooCommerce Core

### Revert "Performance: Cache script data in a transient for production builds" [#10509](https://github.com/woocommerce/woocommerce-blocks/pull/10509)

1. Smoke test blocks.

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 @@ -162,6 +162,7 @@ Every release includes specific testing instructions for new features and bug fi
- [10.6.2](./1062.md)
- [10.6.3](./1063.md)
- [10.6.4](./1064.md)
- [10.6.5](./1065.md)



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.6.4",
"version": "10.6.5",
"description": "WooCommerce blocks for the Gutenberg editor.",
"homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/",
"keywords": [
Expand Down
16 changes: 11 additions & 5 deletions 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.2
Tested up to: 6.2
Requires PHP: 7.3
Stable tag: 10.6.4
Stable tag: 10.6.5
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

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

== Changelog ==

= 10.6.4 - 2021-08-04 =
= 10.6.5 - 2023-08-09 =

#### Bug Fixes

- Avoid to cache script data in a transient. ([10509](https://github.com/woocommerce/woocommerce-blocks/pull/10509))

= 10.6.4 - 2023-08-04 =

#### Bug Fixes

- Classic Template block registration: add defensive type handling. ([10475](https://github.com/woocommerce/woocommerce-blocks/pull/10475))
- Fixed an issue where modifications to the Cart/Checkout templates made in the site editor would not be visible on the front end. [#10462](https://github.com/woocommerce/woocommerce-blocks/pull/10462)

= 10.6.3 - 2021-08-02 =
= 10.6.3 - 2023-08-02 =

#### Bug Fixes

- Fix styles for the Add to Cart Form block when used together with the Single Product block. ([10282](https://github.com/woocommerce/woocommerce-blocks/pull/10282))
- Blockified templates: Improve migration logic. [#10415](https://github.com/woocommerce/woocommerce-blocks/pull/10415)

= 10.6.2 - 2021-07-31 =
= 10.6.2 - 2023-07-31 =

#### Enhancements

Expand All @@ -111,7 +117,7 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/
- Single Product Template > Ensure extensions can't trigger fatal errors on customized single product templates without any post content blocks. ([10128](https://github.com/woocommerce/woocommerce-blocks/pull/10128))
- Cart and Checkout Page Migration: Inherit Page template and fix rendering. ([10375](https://github.com/woocommerce/woocommerce-blocks/pull/10375))

= 10.6.1 - 2021-07-17 =
= 10.6.1 - 2023-07-17 =

#### Bug Fixes

Expand Down
104 changes: 22 additions & 82 deletions src/Assets/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ class Api {
*/
private $inline_scripts = [];

/**
* Determines if caching is enabled for script data.
*
* @var boolean
*/
private $disable_cache = false;

/**
* Stores loaded script data for the current request
*
* @var array|null
*/
private $script_data = null;

/**
* Reference to the Package instance
*
Expand All @@ -45,9 +31,7 @@ class Api {
* @param Package $package An instance of Package.
*/
public function __construct( Package $package ) {
$this->package = $package;
$this->disable_cache = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || ! $this->package->feature()->is_production_environment();
add_action( 'shutdown', array( $this, 'update_script_data_cache' ), 20 );
$this->package = $package;
}

/**
Expand Down Expand Up @@ -92,44 +76,6 @@ public function get_block_metadata_path( $block_name, $path = '' ) {
return $path_to_metadata_from_plugin_root;
}

/**
* Initialize and load cached script data from the transient cache.
*
* @return array
*/
private function get_cached_script_data() {
if ( $this->disable_cache ) {
return [];
}

$transient_value = json_decode( (string) get_transient( 'woocommerce_blocks_asset_api_script_data' ), true );

if ( empty( $transient_value ) || empty( $transient_value['script_data'] ) || empty( $transient_value['version'] ) || $transient_value['version'] !== $this->package->get_version() ) {
return [];
}

return (array) ( $transient_value['script_data'] ?? [] );
}

/**
* Store all cached script data in the transient cache.
*/
public function update_script_data_cache() {
if ( is_null( $this->script_data ) || $this->disable_cache ) {
return;
}
set_transient(
'woocommerce_blocks_asset_api_script_data',
wp_json_encode(
array(
'script_data' => $this->script_data,
'version' => $this->package->get_version(),
)
),
DAY_IN_SECONDS * 30
);
}

/**
* Get src, version and dependencies given a script relative src.
*
Expand All @@ -139,37 +85,31 @@ public function update_script_data_cache() {
* @return array src, version and dependencies of the script.
*/
public function get_script_data( $relative_src, $dependencies = [] ) {
if ( ! $relative_src ) {
return array(
'src' => '',
'version' => '1',
'dependencies' => $dependencies,
);
}

if ( is_null( $this->script_data ) ) {
$this->script_data = $this->get_cached_script_data();
}

if ( empty( $this->script_data[ $relative_src ] ) ) {
$asset_path = $this->package->get_path( str_replace( '.js', '.asset.php', $relative_src ) );
// The following require is safe because we are checking if the file exists and it is not a user input.
// nosemgrep audit.php.lang.security.file.inclusion-arg.
$asset = file_exists( $asset_path ) ? require $asset_path : [];
$src = '';
$version = '1';

$this->script_data[ $relative_src ] = array(
'src' => $this->get_asset_url( $relative_src ),
'version' => ! empty( $asset['version'] ) ? $asset['version'] : $this->get_file_version( $relative_src ),
'dependencies' => ! empty( $asset['dependencies'] ) ? $asset['dependencies'] : [],
if ( $relative_src ) {
$src = $this->get_asset_url( $relative_src );
$asset_path = $this->package->get_path(
str_replace( '.js', '.asset.php', $relative_src )
);

if ( file_exists( $asset_path ) ) {
// The following require is safe because we are checking if the file exists and it is not a user input.
// nosemgrep audit.php.lang.security.file.inclusion-arg.
$asset = require $asset_path;
$dependencies = isset( $asset['dependencies'] ) ? array_merge( $asset['dependencies'], $dependencies ) : $dependencies;
$version = ! empty( $asset['version'] ) ? $asset['version'] : $this->get_file_version( $relative_src );
} else {
$version = $this->get_file_version( $relative_src );
}
}

// Return asset details as well as the requested dependencies array.
return [
'src' => $this->script_data[ $relative_src ]['src'],
'version' => $this->script_data[ $relative_src ]['version'],
'dependencies' => array_merge( $this->script_data[ $relative_src ]['dependencies'], $dependencies ),
];
return array(
'src' => $src,
'version' => $version,
'dependencies' => $dependencies,
);
}

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

0 comments on commit 7ca3489

Please sign in to comment.