From 6e0cee863eab25605ece73d45265f742316d1bd1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 12:14:10 +0000 Subject: [PATCH 1/3] Initial plan From 722fc5f06df0ba07ec201c5549cc61eaf4b3c9f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 12:22:10 +0000 Subject: [PATCH 2/3] Differentiate between empty and null for Stores field - Modified Multiselect::preGetData to preserve null values - Added isEmpty method to treat null as empty but not [] - Updated all callers to handle null with ?? [] operator Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com> --- .../Behat/Context/Setup/ProductContext.php | 2 +- .../Controller/CategoryController.php | 2 +- .../Controller/ProductController.php | 2 +- .../CoreExtension/Multiselect.php | 22 +++++++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/CoreShop/Behat/Context/Setup/ProductContext.php b/src/CoreShop/Behat/Context/Setup/ProductContext.php index 85d16c261a..9b46e587a9 100644 --- a/src/CoreShop/Behat/Context/Setup/ProductContext.php +++ b/src/CoreShop/Behat/Context/Setup/ProductContext.php @@ -118,7 +118,7 @@ public function theSiteHasAProductPricedAt(string $productName, int $price = 100 */ public function theProductIsPriced(ProductInterface $product, int $price, StoreInterface $store): void { - $product->setStores(array_merge($product->getStores(), [$store->getId()])); + $product->setStores(array_merge($product->getStores() ?? [], [$store->getId()])); $product->setStoreValuesOfType('price', $price, $store); $this->saveProduct($product); diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php index 7205bb89bc..2fbcc2772c 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php @@ -258,7 +258,7 @@ protected function validateCategory(Request $request, CategoryInterface $categor throw new NotFoundHttpException('category not found'); } - if (!in_array($this->getContext()->getStore()->getId(), array_values($category->getStores()))) { + if (!in_array($this->getContext()->getStore()->getId(), array_values($category->getStores() ?? []))) { throw new NotFoundHttpException( sprintf(sprintf('store (id %s) not available in category', $this->getContext()->getStore()->getId())), ); diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/ProductController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/ProductController.php index 6b9d38703f..7c42e7852a 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/ProductController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/ProductController.php @@ -82,7 +82,7 @@ protected function validateProduct(Request $request, ProductInterface $product): throw new NotFoundHttpException('product not found'); } - if (!in_array($this->container->get(StoreContextInterface::class)->getStore()->getId(), $product->getStores())) { + if (!in_array($this->container->get(StoreContextInterface::class)->getStore()->getId(), $product->getStores() ?? [])) { throw new NotFoundHttpException('product not found'); } } diff --git a/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php b/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php index 4848687a73..59385583ac 100644 --- a/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php +++ b/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php @@ -48,10 +48,24 @@ public function preGetData($object, $params = []) $data = $object->getObjectVar($this->getName()); - if (null === $data) { - $data = []; - } - + // Don't convert null to empty array to allow Pimcore's inheritance to work + // null means "not set" and will inherit from parent + // empty array means "explicitly set to no values" and won't inherit return $data; } + + /** + * Checks if data is empty. Returns true only for null, not for empty arrays. + * This allows differentiating between "not set" (null) and "explicitly empty" ([]). + * + * @param mixed $data + * + * @return bool + */ + public function isEmpty($data): bool + { + // Only null is considered empty (will inherit from parent) + // Empty array [] is NOT empty (explicitly set to no values, won't inherit) + return null === $data; + } } From 447151cd97f2ce75e92c9f9fad747e16052c131d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 12:24:12 +0000 Subject: [PATCH 3/3] Address code review comments - Improve isEmpty docstring to specify array|null type - Remove redundant double sprintf in CategoryController Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com> --- .../Bundle/FrontendBundle/Controller/CategoryController.php | 2 +- .../Bundle/ResourceBundle/CoreExtension/Multiselect.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php index 2fbcc2772c..e28b51251a 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/CategoryController.php @@ -260,7 +260,7 @@ protected function validateCategory(Request $request, CategoryInterface $categor if (!in_array($this->getContext()->getStore()->getId(), array_values($category->getStores() ?? []))) { throw new NotFoundHttpException( - sprintf(sprintf('store (id %s) not available in category', $this->getContext()->getStore()->getId())), + sprintf('store (id %s) not available in category', $this->getContext()->getStore()->getId()), ); } } diff --git a/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php b/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php index 59385583ac..32c119487c 100644 --- a/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php +++ b/src/CoreShop/Bundle/ResourceBundle/CoreExtension/Multiselect.php @@ -58,7 +58,7 @@ public function preGetData($object, $params = []) * Checks if data is empty. Returns true only for null, not for empty arrays. * This allows differentiating between "not set" (null) and "explicitly empty" ([]). * - * @param mixed $data + * @param array|null $data * * @return bool */