magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.4k stars 9.29k forks source link

Noticed exception 'TypeError' when the product_list_order parameter is an array. #37827

Open adam-krakowski-accenture opened 11 months ago

adam-krakowski-accenture commented 11 months ago

Preconditions and environment

Steps to reproduce

  1. Go to storefront, then into categories to see the products.
  2. Change the product_list_order parameter in the URL to an array type.
  3. Refresh the page with changed URL.

Examples of URL: https://release4.proshop.pg.com/whitening/crest-whitestrips.html?product_list_order[]=price&product_list_dir=desc https://ca.magento2.local/shop-by-product/crest-whitening.html?product_list_order[]

Expected result

The product_list_order parameter with an array type is handled correctly.

vendor/magento/module-catalog/Model/Product/ProductList/ToolbarMemorizer.php The getOrder() function returns string|bool value as described in the @return tag

Actual result

TypeError: Illegal offset type in isset or empty in /var/www/magento/vendor/magento/module-catalog/Block/Product/ProductList/Toolbar.php:280

vendor/magento/module-catalog/Model/Product/ProductList/ToolbarMemorizer.php The getOrder() function returns array value (invalid @return tag), which causes a TypeError

Additional information

TypeError: Illegal offset type in isset or empty in /var/www/magento/vendor/magento/module-catalog/Block/Product/ProductList/Toolbar.php:280 Stack trace:

0 /var/www/magento/app/code/PG/GaGtm/Model/ProductCollection/CategoryCollectionFilter.php(62): Magento\Catalog\Block\Product\ProductList\Toolbar->getCurrentOrder()

1 /var/www/magento/app/code/PG/GaGtm/Model/ProductCollection/CollectionGetter.php(46): PG\GaGtm\Model\ProductCollection\CategoryCollectionFilter->filter()

2 /var/www/magento/app/code/PG/GaGtm/Observer/Products/LoadCollection.php(58): PG\GaGtm\Model\ProductCollection\CollectionGetter->getCollection()

3 /var/www/magento/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): PG\GaGtm\Observer\Products\LoadCollection->execute()

4 /var/www/magento/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()

5 /var/www/magento/vendor/magento/module-staging/Model/Event/Manager.php(97): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()

6 /var/www/magento/generated/code/Magento/Staging/Model/Event/Manager/Proxy.php(95): Magento\Staging\Model\Event\Manager->dispatch()

7 /var/www/magento/vendor/magento/framework/View/Result/Layout.php(169): Magento\Staging\Model\Event\Manager\Proxy->dispatch()

8 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult()

9 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent()

10 /var/www/magento/vendor/magezon/module-core/Plugin/View/Result/Layout.php(24): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception{closure}()

11 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(135): Magezon\Core\Plugin\View\Result\Layout->aroundRenderResult()

12 /var/www/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception{closure}()

13 /var/www/magento/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(95): Magento\Framework\View\Result\Page\Interceptor->___callPlugins()

14 /var/www/magento/vendor/magento/framework/App/Http.php(120): Magento\Framework\View\Result\Page\Interceptor->renderResult()

15 /var/www/magento/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()

16 /var/www/magento/vendor/magento/framework/App/Bootstrap.php(267): Magento\Framework\App\Http\Interceptor->launch()

17 /var/www/magento/pub/index.php(30): Magento\Framework\App\Bootstrap->run()

Release note

No response

Triage and priority

m2-assistant[bot] commented 11 months ago

Hi @adam-krakowski-accenture. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

engcom-Dash commented 11 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 11 months ago

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 11 months ago

Hi @engcom-Dash, here is your Magento Instance: https://363deb92f651eefc97cf2debc5e32652.instances-prod.magento-community.engineering Admin access: https://363deb92f651eefc97cf2debc5e32652.instances-prod.magento-community.engineering/admin_c255 Login: 98dc9224 Password: 182456bf51e8

m2-assistant[bot] commented 11 months ago

Hi @engcom-Bravo. 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: :point_down:

engcom-Bravo commented 11 months ago

Hi @adam-krakowski-accenture,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the attached video.

Steps to reproduce

We are not getting any exception after changing the URL could you please let us know if we are missing anything.

https://github.com/magento/magento2/assets/51680745/5d724bd5-a71a-42d0-9e4e-892c9fd159b7

Kindly recheck the behaviour on Magento 2.4-develop instance and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

adam-krakowski-accenture commented 11 months ago

Hello @engcom-Bravo, Thank you for contact. Please try to change URL with sign "?" also. On the video I see that you are trying for example "product_list_order[]" instead "?product_list_order[] after ".html" so at the end of URL should be ".html?product_list_order[]". Thanks

engcom-Bravo commented 11 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 11 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 11 months ago

Hi @engcom-Bravo, here is your Magento Instance: https://363deb92f651eefc97cf2debc5e32652.instances-prod.magento-community.engineering Admin access: https://363deb92f651eefc97cf2debc5e32652.instances-prod.magento-community.engineering/admin_5876 Login: 5bc0eabd Password: de28f78b65bf

engcom-Bravo commented 11 months ago

Hi @adam-krakowski-accenture,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible. Kindly refer the attached video.

Steps to reproduce

After changing the URL to an array type we are getting exception An error has happened during application run. See exception log for details.

Screenshot 2023-08-03 at 5 04 29 PM

https://github.com/magento/magento2/assets/51680745/f8481389-d33b-4006-8bfa-1ffc68919935

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 11 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9253 is successfully created for this GitHub issue.

m2-assistant[bot] commented 11 months ago

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

jenyatrishin commented 11 months ago

@magento I am working on this

m2-assistant[bot] commented 11 months ago

Hi @jenyatrishin! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

jenyatrishin commented 11 months ago

@magento add to contributors team

m2-assistant[bot] commented 11 months ago

Hi @jenyatrishin! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

jenyatrishin commented 11 months ago

@magento I am working on this