From 8ff4fe5f726c20ac59668528b4bedc4877e8838b Mon Sep 17 00:00:00 2001 From: Jonathan Sacksick <21182-jsacksick@users.noreply.drupalcode.org> Date: Fri, 10 Feb 2023 09:59:41 +0200 Subject: [PATCH] Issue #3340445 by fraserthompson, jsacksick: Non-strict comparison when checking if product is in current store can cause a fatal error. --- modules/store/src/SelectStoreTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/store/src/SelectStoreTrait.php b/modules/store/src/SelectStoreTrait.php index 750f5c32f..f7014ffa8 100644 --- a/modules/store/src/SelectStoreTrait.php +++ b/modules/store/src/SelectStoreTrait.php @@ -2,6 +2,7 @@ namespace Drupal\commerce_store; +use Drupal\commerce\EntityHelper; use Drupal\commerce\PurchasableEntityInterface; /** @@ -43,7 +44,8 @@ trait SelectStoreTrait { } else { $store = $this->currentStore->getStore(); - if (!in_array($store, $stores)) { + $store_ids = EntityHelper::extractIds($stores); + if (!in_array($store->id(), $store_ids, TRUE)) { // Indicates that the site listings are not filtered properly. throw new \Exception("The given entity can't be purchased from the current store."); } -- GitLab