From 7f81e8b9ae9fe75a3bbe69f8c475cdb5cc348a6f Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Tue, 3 Jan 2023 21:23:18 +0100 Subject: [PATCH] Fixed various PHP8 issues --- system/modules/isotope/library/Isotope/Model/Product.php | 4 ++-- .../isotope/library/Isotope/Model/Product/Standard.php | 8 ++++---- .../modules/isotope/library/Isotope/Model/ProductType.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/system/modules/isotope/library/Isotope/Model/Product.php b/system/modules/isotope/library/Isotope/Model/Product.php index f507f25d79..1f39693b7c 100644 --- a/system/modules/isotope/library/Isotope/Model/Product.php +++ b/system/modules/isotope/library/Isotope/Model/Product.php @@ -412,7 +412,7 @@ public static function findDefaultVariantOfProduct(IsotopeProduct $objProduct, a } } - $defaultId = $cache[$objProduct->getProductId()]; + $defaultId = $cache[$objProduct->getProductId()] ?? null; if ($defaultId < 1 || !\in_array($defaultId, $objProduct->getVariantIds())) { return null; @@ -622,7 +622,7 @@ protected static function buildFindQuery(array $arrOptions) str_replace('-', '_', $GLOBALS['TL_LANGUAGE']) ); - $arrOptions['group'] = (null === $arrOptions['group'] ? '' : $arrOptions['group'].', ') . 'translation.id'; + $arrOptions['group'] = (empty($arrOptions['group']) ? '' : $arrOptions['group'].', ') . 'translation.id'; } if ($hasVariants) { diff --git a/system/modules/isotope/library/Isotope/Model/Product/Standard.php b/system/modules/isotope/library/Isotope/Model/Product/Standard.php index 5f2f8314ba..f688b2a3cd 100644 --- a/system/modules/isotope/library/Isotope/Model/Product/Standard.php +++ b/system/modules/isotope/library/Isotope/Model/Product/Standard.php @@ -724,8 +724,8 @@ protected function generateProductOptionWidget($strField, &$arrVariantOptions, & if ($objAttribute->isVariantOption() || ($objAttribute instanceof IsotopeAttributeWithOptions && $objAttribute->canHavePrices()) - || $arrData['attributes']['ajax_option'] - || $arrField['attributes']['ajax_option'] // see https://github.com/isotope/core/issues/2096 + || ($arrData['attributes']['ajax_option'] ?? null) + || ($arrField['attributes']['ajax_option'] ?? null) // see https://github.com/isotope/core/issues/2096 ) { $arrAjaxOptions[] = $strField; } @@ -733,7 +733,7 @@ protected function generateProductOptionWidget($strField, &$arrVariantOptions, & // Convert optgroups so they work with FormSelectMenu // @deprecated Remove in Isotope 3.0, the options should match for frontend if attribute is customer defined if ( - \is_array($arrField['options']) + \is_array($arrField['options'] ?? null) && array_is_assoc($arrField['options']) && \count( array_filter( @@ -906,7 +906,7 @@ public function validateVariant($loadDefaultVariant = true) if (Input::post('FORM_SUBMIT') == $this->getFormId() && \in_array(Input::post($attribute), $arrValues)) { $arrOptions[$attribute] = Input::post($attribute); - } elseif (Input::post('FORM_SUBMIT') == '' && \in_array($arrDefaults[$attribute], $arrValues)) { + } elseif (Input::post('FORM_SUBMIT') == '' && isset($arrDefaults[$attribute]) && \in_array($arrDefaults[$attribute], $arrValues)) { $arrOptions[$attribute] = $arrDefaults[$attribute]; } elseif (\count($arrValues) == 1) { $arrOptions[$attribute] = $arrValues[0]; diff --git a/system/modules/isotope/library/Isotope/Model/ProductType.php b/system/modules/isotope/library/Isotope/Model/ProductType.php index c184edf272..563ff9c68b 100644 --- a/system/modules/isotope/library/Isotope/Model/ProductType.php +++ b/system/modules/isotope/library/Isotope/Model/ProductType.php @@ -172,7 +172,7 @@ protected function getEnabledAttributesByPosition($varValue) $arrAttributes = array_filter($arrAttributes, function ($a) use ($arrFields) { return ($a['enabled'] - && \is_array($arrFields[$a['name']]) + && \is_array($arrFields[$a['name']] ?? null) && $arrFields[$a['name']]['attributes']['legend'] != '' ); });