Commit f8041807020 for woocommerce
commit f80418070206f64bc7f7c82a929e6b47681e0ee5
Author: Lovro Hrust <33687174+Lovor01@users.noreply.github.com>
Date: Mon Apr 13 16:25:25 2026 +0200
Fix bug - force page reload never fires (#63054)
* Add parsed_block to render_product_collection_callback
Fix bug because $parsed_block is out of scope inside function
* Use block instead of parsed_block variable
* Add changelog
* Update PHPStan
* Fix wrong priority in check
* Update PHPStan (II)
* Fix another broken expression
* PHPStan udpate
---------
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/patch-1 b/plugins/woocommerce/changelog/patch-1
new file mode 100644
index 00000000000..5df0e6289c3
--- /dev/null
+++ b/plugins/woocommerce/changelog/patch-1
@@ -0,0 +1,5 @@
+Significance: patch
+Type: fix
+Comment: Replace incorrect variable usage in ProductCollection PHP file
+
+
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 7c252a05ebf..4ca0a17cf95 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -53259,18 +53259,6 @@ parameters:
count: 1
path: src/Blocks/BlockTypes/ProductCollection/Controller.php
- -
- message: '#^If condition is always false\.$#'
- identifier: if.alwaysFalse
- count: 1
- path: src/Blocks/BlockTypes/ProductCollection/Controller.php
-
- -
- message: '#^Left side of && is always false\.$#'
- identifier: booleanAnd.leftAlwaysFalse
- count: 2
- path: src/Blocks/BlockTypes/ProductCollection/Controller.php
-
-
message: '#^Method Automattic\\WooCommerce\\Blocks\\BlockTypes\\ProductCollection\\Controller\:\:add_support_for_filter_blocks\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -53331,12 +53319,6 @@ parameters:
count: 1
path: src/Blocks/BlockTypes/ProductCollection/Controller.php
- -
- message: '#^Variable \$parsed_block on left side of \?\? is never defined\.$#'
- identifier: nullCoalesce.variable
- count: 1
- path: src/Blocks/BlockTypes/ProductCollection/Controller.php
-
-
message: '#^Call to an undefined method WC_Order_Item\:\:get_product_id\(\)\.$#'
identifier: method.notFound
@@ -53721,7 +53703,6 @@ parameters:
count: 1
path: src/Blocks/BlockTypes/ProductFilterAttribute.php
-
-
message: '#^Method Automattic\\WooCommerce\\Blocks\\BlockTypes\\ProductFilterAttribute\:\:delete_default_attribute_id_transient\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -65035,7 +65016,6 @@ parameters:
count: 1
path: src/Internal/EmailEditor/WCTransactionalEmails/WCTransactionalEmails.php
-
-
message: '#^@param string \$feature_id does not accept actual type of parameter\: int\<min, \-1\>\|int\<1, max\>\|non\-falsy\-string\.$#'
identifier: parameter.phpDocType
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/Controller.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/Controller.php
index 96c5faadca9..be3b4727d93 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/Controller.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/Controller.php
@@ -149,7 +149,7 @@ class Controller extends AbstractBlock {
$block_name = $parsed_block['blockName'];
$is_product_collection_block = $parsed_block['attrs']['query']['isProductCollectionBlock'] ?? false;
$force_page_reload_global =
- $parsed_block['attrs']['forcePageReload'] ?? false &&
+ ( $parsed_block['attrs']['forcePageReload'] ?? false ) &&
isset( $parsed_block['attrs']['queryId'] );
if (
@@ -173,7 +173,7 @@ class Controller extends AbstractBlock {
*/
$render_product_collection_callback = static function ( $content, $block ) use ( &$enhanced_query_stack, &$dirty_enhanced_queries, &$render_product_collection_callback ) {
$force_page_reload =
- $parsed_block['attrs']['forcePageReload'] ?? false &&
+ ( $block['attrs']['forcePageReload'] ?? false ) &&
isset( $block['attrs']['queryId'] );
if ( $force_page_reload ) {