From 30d6c21592dce4c6e0c629a3c586c4b915489780 Mon Sep 17 00:00:00 2001 From: Marco Schrenk Date: Tue, 27 Jan 2026 18:52:58 +0100 Subject: [PATCH] fixing PHP 8 warings if key not set --- Classes/Controller/ProductController.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php index bb79303..f2f8105 100644 --- a/Classes/Controller/ProductController.php +++ b/Classes/Controller/ProductController.php @@ -61,7 +61,7 @@ protected function initializeAction(): void } } - $this->settings['addToCartByAjax'] = isset($this->settings['addToCartByAjax']) ? (int)$this->settings['addToCartByAjax'] : 0; + $this->settings['addToCartByAjax'] = (int)($this->settings['addToCartByAjax'] ?? 0); } /** @@ -80,7 +80,7 @@ protected function createDemandObjectFromSettings(array $settings): ProductDeman if (!empty($this->searchArguments['title'])) { $demand->setTitle($this->searchArguments['title']); } - if ($settings['orderBy']) { + if ($settings['orderBy'] ?? false) { if ( !isset($settings['orderDirection']) && $settings['orderDirection'] !== 'DESC' @@ -97,7 +97,7 @@ protected function createDemandObjectFromSettings(array $settings): ProductDeman protected function addCategoriesToDemandObjectFromSettings(ProductDemand $demand): void { - if ($this->settings['categoriesList']) { + if ($this->settings['categoriesList'] ?? false) { $selectedCategories = GeneralUtility::intExplode( ',', $this->settings['categoriesList'], @@ -106,7 +106,7 @@ protected function addCategoriesToDemandObjectFromSettings(ProductDemand $demand $categories = []; - if ($this->settings['listSubcategories']) { + if ($this->settings['listSubcategories'] ?? false) { foreach ($selectedCategories as $selectedCategory) { $category = $this->categoryRepository->findByUid($selectedCategory); $categories = array_merge( @@ -333,7 +333,8 @@ protected function addCacheTags(iterable $products): void protected function restoreSession(): void { - $cart = $this->sessionHandler->restoreCart($this->cartConfiguration['settings']['cart']['pid']); + $pid = (int)($this->cartConfiguration['settings']['cart']['pid'] ?? 0); + $cart = $this->sessionHandler->restoreCart($pid); if ($cart instanceof Cart) { $this->cart = $cart; @@ -341,6 +342,6 @@ protected function restoreSession(): void } $this->cart = $this->cartUtility->getNewCart($this->cartConfiguration); - $this->sessionHandler->writeCart($this->cartConfiguration['settings']['cart']['pid'], $this->cart); + $this->sessionHandler->writeCart($pid, $this->cart); } }