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

strlen() expects parameter 1 to be string, array given | magento/module-catalog-search #33589

Closed
1 of 5 tasks
Morgy93 opened this issue Jul 26, 2021 · 18 comments · Fixed by #33682
Closed
1 of 5 tasks
Assignees
Labels
Component: Url Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@Morgy93
Copy link
Member

Morgy93 commented Jul 26, 2021

Preconditions (*)

  • Magento 2.4.2
  • PHP 7.4

Steps to reproduce (*)

  1. Go to /catalogsearch/advanced/result/?price[from][]=1&price[to]=1
  2. On trying to access above URL from front-end, "There has been an error processing your request" error message is getting displayed on UI:
    http://magento2.4.local/catalogsearch/advanced/result/?price[from][]=1&price[to]=1
    image

Expected result (*)

It should not throw an unhandled error.

Actual result (*)

Exception #0 (Exception): Warning: strlen() expects parameter 1 to be string, array given in vendor/magento/module-catalog-search/Model/Advanced.php on line 380

#1 strlen() called at [vendor/magento/module-catalog-search/Model/Advanced.php:380]
#2 Magento\CatalogSearch\Model\Advanced->getPreparedSearchCriteria() called at [vendor/magento/module-catalog-search/Model/Advanced.php:206]
#3 Magento\CatalogSearch\Model\Advanced->addFilters() called at [vendor/magento/module-catalog-search/Controller/Advanced/Result.php:62]
#4 Magento\CatalogSearch\Controller\Advanced\Result->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#5 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#6 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51]
#7 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#8 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#9 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callPlugins() called at [generated/code/Magento/CatalogSearch/Controller/Advanced/Result/Interceptor.php:23]
#10 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#11 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#12 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#13 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#14 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callPlugins() called at [generated/code/Magento/CatalogSearch/Controller/Advanced/Result/Interceptor.php:32]
#15 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:186]
#16 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:118]
#17 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#18 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#19 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:99]
#20 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#21 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:71]
#22 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#23 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#24 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23]
#25 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#26 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#27 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:29]

Issue 2: strpos() expects parameter 1 to be string, array given | magento/module-eav #33588
Steps to reproduce:

  1. Admin: Stores -> Attributes -> Product - > Add New Attribute /Choose existing attribute ex: color
    Input Type should be: Dropdown
    Storefront Properties: Use in Search: Yes, Visible in Advanced Search: Yes
  2. Front-end - Go to http://yourmagentostore.com/catalogsearch/advanced/result/?attributename[][error]=1
    Ex: https://magento2.4.local/catalogsearch/advanced/result/?test_data[][error]=1
    Issue: There has been an error processing your request Error message is getting displayed
    Note: There is no issue with Text Attribute. URL is working for Text attribute. Issue is observed for dropdown attribute.

Magentoroot/var/log/exception.log:

Exception #0 (Exception): Warning: strpos() expects parameter 1 to be string, array given in vendor/magento/module-eav/Model/Entity/Attribute/Source/Table.php on line 152

#1 strpos() called at [vendor/magento/module-eav/Model/Entity/Attribute/Source/Table.php:152]
#2 Magento\Eav\Model\Entity\Attribute\Source\Table->getOptionText() called at [vendor/magento/module-catalog-search/Model/Advanced.php:404]
#3 Magento\CatalogSearch\Model\Advanced->getPreparedSearchCriteria() called at [vendor/magento/module-catalog-search/Model/Advanced.php:206]
#4 Magento\CatalogSearch\Model\Advanced->addFilters() called at [vendor/magento/module-catalog-search/Controller/Advanced/Result.php:62]
#5 Magento\CatalogSearch\Controller\Advanced\Result->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#6 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#7 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php:51]
#8 Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#9 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#10 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callPlugins() called at [generated/code/Magento/CatalogSearch/Controller/Advanced/Result/Interceptor.php:23]
#11 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#12 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#13 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#14 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#15 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->___callPlugins() called at [generated/code/Magento/CatalogSearch/Controller/Advanced/Result/Interceptor.php:32]
#16 Magento\CatalogSearch\Controller\Advanced\Result\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:186]
#17 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:118]
#18 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#19 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#20 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:99]
#21 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#22 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:71]
#23 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#24 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#25 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23]
#26 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#27 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#28 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:29]

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Jul 26, 2021

Hi @Morgy93. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@Morgy93
Copy link
Member Author

Morgy93 commented Jul 26, 2021

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @Morgy93. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Hi @Morgy93, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@Morgy93
Copy link
Member Author

Morgy93 commented Jul 26, 2021

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @Morgy93. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@Morgy93
Copy link
Member Author

Morgy93 commented Jul 26, 2021

Verified the issue on Magento 2.4-develop branch and the issue is reproducible:
Steps to reproduce:

  1. Go to domain.tld/catalogsearch/advanced/result/?price[from][]=1&price[to]=1 (e.g. https://52a58bd3ae67a73e5814b62433f13aee-2-4-develop.instances.magento-community.engineering/catalogsearch/advanced/result/?price[from][]=1&price[to]=1)
  2. See error
    image

@engcom-November engcom-November self-assigned this Jul 29, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jul 29, 2021

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November
Copy link
Contributor

engcom-November commented Jul 29, 2021

Verified the issue on Magento 2.4-develop branch and the issue is reproducible:
On trying to access below URL from front-end, "There has been an error processing your request" error message is getting displayed on UI:
http://magento2.4.local/catalogsearch/advanced/result/?price[from][]=1&price[to]=1
Screenshot 2021-08-25 at 9 35 00 PM

Magentoroot/var/log/exception.log:

main.CRITICAL: Warning: strlen() expects parameter 1 to be string, array given in /var/www/html/magento2.4/magento2/app/code/Magento/CatalogSearch/Model/Advanced.php on line 380 {"report_id":"79cdf9e388c36ce3b8cc8d55f705fca8f8e6a566f6b8c18c11190cc9c4eb90d1","exception":"[object] (Exception(code: 0): Warning: strlen() expects parameter 1 to be string, array given in /var/www/html/magento2.4/magento2/app/code/Magento/CatalogSearch/Model/Advanced.php on line 380 at /var/www/html/magento2.4/magento2/lib/internal/Magento/Framework/App/ErrorHandler.php:61)"} []

@engcom-November engcom-November added Component: Url Reported on 2.4.2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jul 29, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Jul 29, 2021
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-November
Thank you for verifying the issue. Based on the provided information internal tickets MC-42934 were created

Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@SilinMykola
Copy link
Contributor

@magento I am working on this

@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Aug 3, 2021
@andrewbess
Copy link

Hello @Morgy93
I am not sure issue is correct.
In basically, you have wrong search request there.
So, this issue is wrong (IMHO)

cc @engcom-November cc @SilinMykola

@Morgy93
Copy link
Member Author

Morgy93 commented Aug 4, 2021

Hello @Morgy93
I am not sure issue is correct.
In basically, you have wrong search request there.
So, this issue is wrong (IMHO)

cc @engcom-November cc @SilinMykola

It triggers a 500 server error so it is an issue, isn't it? =)

It was discovered while someone tried to hack into the system, so yes, it might not be "usual customer behavior", but still an (security) issue.

@engcom-November
Copy link
Contributor

@andrewbess for wrong Search requests like this, User should not be displayed with exception/unhandled errors. Error handling should be made for better user experience and to avoid security issues.
@Morgy93, Similar kind of issue but has different error messages is closed as duplicate and updated here in the description.
Thank you

@andrewbess
Copy link

andrewbess commented Aug 5, 2021

I understand you @engcom-November @Morgy93
But I think we shouldn't process all request with wrong GET params.
Of course, end user shouldn't see report message of the 500 error.
I think it would be better don't process wrong params or to redirect user to page 404 in this case.
Anyway we should consult behaviour with product owners if we want to process it.

cc @hostep @eduard13

@hostep
Copy link
Contributor

hostep commented Aug 5, 2021

I think the validation of those parameters should be broadened a bit, currently it only validates if from or to aren't empty (whatever that means, I really hate the empty function in php btw).
So we should probably expand the validation to check that those values match what is expected, and if those don't validate , then return an empty string or false (whatever makes sense).

Just my 2 cents I'm not very familiar with this part in magento's codebase.

@sidolov
Copy link
Contributor

sidolov commented Sep 23, 2021

Hi @Morgy93. Thank you for your report.
The issue has been fixed in #33682 by @SilinMykola in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.4 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Url Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

Successfully merging a pull request may close this issue.

8 participants