diff --git a/plugins/woocommerce/changelog/43044-fix-42975-collection-data-leak b/plugins/woocommerce/changelog/43044-fix-42975-collection-data-leak new file mode 100644 index 00000000000..23a4cbea7f3 --- /dev/null +++ b/plugins/woocommerce/changelog/43044-fix-42975-collection-data-leak @@ -0,0 +1,4 @@ +Significance: patch +Type: fix +Comment: Fix the collection data cache being leak between `Collection Filters` blocks. + diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/CollectionFilters.php b/plugins/woocommerce/src/Blocks/BlockTypes/CollectionFilters.php index 26c493b96a5..c95cea6af44 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/CollectionFilters.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/CollectionFilters.php @@ -53,25 +53,6 @@ final class CollectionFilters extends AbstractBlock { add_action( 'render_block_context', array( $this, 'modify_inner_blocks_context' ), 10, 3 ); } - /** - * Extra data passed through from server to client for block. - * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. - */ - protected function enqueue_data( array $attributes = [] ) { - parent::enqueue_data( $attributes ); - - if ( ! is_admin() ) { - /** - * At this point, WP starts rendering the Collection Filters block, - * we can safely unset the current response. - */ - $this->current_response = null; - } - } - /** * Render the block. * @@ -81,6 +62,16 @@ final class CollectionFilters extends AbstractBlock { * @return string Rendered block type output. */ protected function render( $attributes, $content, $block ) { + if ( is_admin() ) { + return $content; + } + + /** + * At this point, WP starts rendering the Collection Filters block, + * we can safely unset the current response. + */ + $this->current_response = null; + $attributes_data = array( 'data-wc-interactive' => wp_json_encode( array( 'namespace' => 'woocommerce/collection-filters' ) ), 'class' => 'wc-block-collection-filters',