Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cart: str_contains(): Argument #1 ($haystack) must be of type string, array given #210

Closed
AlexanderWillner opened this issue May 27, 2023 · 4 comments
Labels

Comments

@AlexanderWillner
Copy link

Description: In Isotope Cart: str_contains(): Argument #1 ($haystack) must be of type string, array given
Version: Contao 4.25.25 / Isotope 2.8 / Haste 4.25.25
URL: https://localhost/warenkorb.html

Steps that will reproduce the problem?

  1. Contao / Isotope Backend: define a product with a multi-select attribute
  2. Contao / Isotope Frontend: select multiple values in said attribute + add to cart

What is the expected result?
Product in cart.

What happens instead?
str_contains(): Argument #1 ($haystack) must be of type string, array given

Possible workaround
In /vendor/codefog/contao-haste/library/Haste/Util/Format.php:166:

- if (isset($arrField['eval']['csv']) && str_contains($varValue, $arrField['eval']['csv'])) {
+ if (isset($arrField['eval']['csv']) && !is_array($varValue) && str_contains($varValue, $arrField['eval']['csv'])) {

Any additional information:

Screenshot of product in frontend:
image

Stack Trace:

in vendor/codefog/contao-haste/library/Haste/Util/Format.php (line 166)
in vendor/codefog/contao-haste/library/Haste/Util/Format.php str_contains (line 166)
in vendor/codefog/contao-haste/library/Haste/Util/Format.php :: dcaValueFromArray (line 132)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Isotope.php :: dcaValue (line 484)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Model/ProductCollection.php :: formatOptions (line 1682)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Model/ProductCollection.php -> generateItem (line 1645)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Model/ProductCollection.php -> addItemsToTemplate (line 1492)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Module/AbstractProductCollection.php -> addToTemplate (line 85)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Module/Cart.php -> compile (line 53)
in vendor/contao/core-bundle/src/Resources/contao/modules/Module.php -> compile (line 214)
in vendor/codefog/contao-haste/library/Haste/Frontend/AbstractFrontendModule.php -> generate (line 52)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Module/Module.php -> generate (line 115)
in vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Module/AbstractProductCollection.php -> generate (line 59)
in vendor/contao/core-bundle/src/Resources/contao/elements/ContentModule.php -> generate (line 98)
in vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php -> generate (line 621)
in vendor/contao/core-bundle/src/Resources/contao/modules/ModuleArticle.php :: getContentElement (line 197)
in vendor/contao/core-bundle/src/Resources/contao/modules/Module.php -> compile (line 214)
in vendor/contao/core-bundle/src/Resources/contao/modules/ModuleArticle.php -> generate (line 70)
in vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php -> generate (line 549)
in vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php :: getArticle (line 391)
in vendor/contao/core-bundle/src/Resources/contao/pages/PageRegular.php :: getFrontendModule (line 190)
in vendor/contao/core-bundle/src/Resources/contao/pages/PageRegular.php -> prepare (line 60)
in vendor/contao/core-bundle/src/Resources/contao/controllers/FrontendIndex.php -> getResponse (line 320)
in vendor/symfony/http-kernel/HttpKernel.php -> renderPage (line 163)
in vendor/symfony/http-kernel/HttpKernel.php -> handleRaw (line 75)
in vendor/symfony/http-kernel/Kernel.php -> handle (line 202)
Kernel->handle(object(Request))
in web/index.php (line 44)
@qzminski
Copy link
Member

@aschempp wdyt?

@beegegroup
Copy link

Same in formatter on line 135. I prepended a $value = (String) $value; before the if statement.

@fritzmg
Copy link
Collaborator

fritzmg commented Jun 7, 2023

I think it should rather be investigated why $varValue is (already) an array at this point.

@aschempp
Copy link
Collaborator

Fixed in b48ed49

@aschempp aschempp added the bug label Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants