From 2a3bd1695d93fe2a8237b262ec862e2b44fc905d Mon Sep 17 00:00:00 2001 From: Valentin Sushkov Date: Thu, 21 Apr 2022 18:27:04 +0300 Subject: [PATCH] Fix a deprecation warning (PHP 8.1 compatibility) Sometimes one of the `$optionTextValues` could be `null`. And in PHP 8 `Passing null to parameter Smile-SA#1 ($string) of type string is deprecated`. So I suggest to explicitly cast all values to string. --- src/module-elasticsuite-catalog/Helper/AbstractAttribute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php b/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php index 1070db0da..ca924ec2d 100644 --- a/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php +++ b/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php @@ -246,7 +246,7 @@ public function prepareIndexValue($attributeId, $storeId, $value) $optionTextFieldName = $this->getOptionTextFieldName($attributeCode); $optionTextValues = $this->getIndexOptionsText($attributeId, $storeId, $value); // Filter empty values. Not using array_filter here because it could remove "0" string from values. - $optionTextValues = array_diff(array_map('trim', $optionTextValues), ['', null, false]); + $optionTextValues = array_diff(array_map('trim', array_map('strval', $optionTextValues)), ['', null, false]); $optionTextValues = array_values($optionTextValues); $values[$optionTextFieldName] = $optionTextValues; }