Skip to content

magento/magento2#33588: strpos() expects parameter 1 to be string, ar…#40422

Open
KrasnoshchokBohdan wants to merge 12 commits intomagento:2.4-developfrom
KrasnoshchokBohdan:fix-for-issue-33588
Open

magento/magento2#33588: strpos() expects parameter 1 to be string, ar…#40422
KrasnoshchokBohdan wants to merge 12 commits intomagento:2.4-developfrom
KrasnoshchokBohdan:fix-for-issue-33588

Conversation

@KrasnoshchokBohdan
Copy link
Copy Markdown
Contributor

@KrasnoshchokBohdan KrasnoshchokBohdan commented Jan 9, 2026

Description (*)

Fixed a critical bug in the advanced search functionality where accessing dropdown/select attributes with array parameters causes a PHP warning "Undefined array key 'label'".

The issue occurred in getPreparedSearchCriteria() method when getOptionText() returns an array without a 'label' key. This happened when dropdown attributes were passed as URL array parameters (e.g., color[]=49,50).

Changes made:

  • Added null coalescing operator (??) on lines 405 and 412 in app/code/Magento/CatalogSearch/Model/Advanced.php to safely handle cases where the 'label' key doesn't exist in the array returned by getOptionText()
  • Added unit test coverage with two new test cases: color_select_without_label and color_multiselect_without_label to prevent regression

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes strpos() expects parameter 1 to be string, array given | magento/module-eav #33588

Manual testing scenarios (*)

  1. In Admin, navigate to Stores → Attributes → Product
  2. Create or select a dropdown attribute (e.g., "color")
  3. Enable "Use in Search" and "Visible in Advanced Search" for the attribute
  4. Save the attribute and reindex if necessary
  5. Clear cache: bin/magento cache:clean
  6. Navigate to the storefront advanced search results page with array parameters in the URL:
    • Example: /catalogsearch/advanced/result/?color[]=49,50 (where 49,50 - attr option ids)

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

… | magento/module-eav

Handle missing 'label' key in advanced search dropdown attributes.
@m2-assistant
Copy link
Copy Markdown

m2-assistant Bot commented Jan 9, 2026

Hi @KrasnoshchokBohdan. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@KrasnoshchokBohdan
Copy link
Copy Markdown
Contributor Author

@magento run all tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jan 12, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Pull Requests Dashboard Jan 12, 2026
KrasnoshchokBohdan and others added 2 commits February 24, 2026 11:51
- Remove disallowed @author tag
- Add explanation and @see tag to @deprecated annotation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@KrasnoshchokBohdan
Copy link
Copy Markdown
Contributor Author

@magento run all tests

Copy link
Copy Markdown
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @KrasnoshchokBohdan,

Thank you for the contribution!

Please look into the failed tests and also look into the below review comment.

Thank you


/**
* @deprecated 101.0.2
* @deprecated 101.0.2 No alternative available.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something seems contradict, if there no alternative then I think we should remove @see annotation or vice versa.

@engcom-Hotel engcom-Hotel moved this from Pending Review to Changes Requested in Community Dashboard Mar 13, 2026
KrasnoshchokBohdan and others added 3 commits March 21, 2026 13:47
… | magento/module-eav

Remove deprecated catalog config property reference

The `@see` annotation pointing to `Advanced::getAttributes()` was removed for the deprecated `_catalogConfig` property. This change cleans up irrelevant documentation for better code clarity.
@KrasnoshchokBohdan
Copy link
Copy Markdown
Contributor Author

@magento run all tests

@engcom-Dash
Copy link
Copy Markdown
Contributor

@magento run all tests

@engcom-Dash engcom-Dash self-assigned this Mar 31, 2026
@engcom-Dash
Copy link
Copy Markdown
Contributor

@magento run all tests

@engcom-Dash
Copy link
Copy Markdown
Contributor

Hello @KrasnoshchokBohdan,

Thank you for the contribution!

Please look into the failed tests and also look into the below review comment.

Thank you

@engcom-Hotel @KrasnoshchokBohdan As this PR has been pending for quite some time, I’ve started addressing the review comments to help move it forward.

@engcom-Dash
Copy link
Copy Markdown
Contributor

@engcom-Hotel i have fixed the suggested review comment and static test failure. Could you please review the changes so we can further proceed with this PR?

@engcom-Dash engcom-Dash moved this from Changes Requested to Pending Review in Community Dashboard Apr 2, 2026
@ct-prd-projects-boards-automation ct-prd-projects-boards-automation Bot moved this from Pending Review to Review in Progress in Community Dashboard Apr 2, 2026
@engcom-Hotel
Copy link
Copy Markdown
Contributor

@magento run all tests

@engcom-Bravo
Copy link
Copy Markdown
Contributor

Hi @KrasnoshchokBohdan,

Thanks for your Contribution!!.

We have tried to reproduce the issue in Latest 2.4-develop instance and we are not able to reproduce the issue.Please refer the screenshot.

Screenshot 2026-04-09 at 6 16 33 pm Screenshot 2026-04-09 at 6 19 51 pm

Could you please let us know if we are still missing anything.

Thanks.

@engcom-Bravo
Copy link
Copy Markdown
Contributor

Hi @KrasnoshchokBohdan,

As mentioned here #40422 (comment) the issue is not reproducible in Latest 2.4-develop instance Could you please let us know if we are missing anything till then moving to On Hold.

Thanks.

@KrasnoshchokBohdan
Copy link
Copy Markdown
Contributor Author

@engcom-Bravo Hi! I managed to reproduce it on 2.4-develop

Screen.Recording.2026-04-17.at.17.04.17.mov
Screen.Recording.2026-04-17.at.17.07.49.mov

@engcom-Bravo engcom-Bravo moved this to Testing in Progress in Community Dashboard Apr 22, 2026
@engcom-Bravo
Copy link
Copy Markdown
Contributor

Hi @KrasnoshchokBohdan,

Thanks for the collaboration & contribution!

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop

Steps to Reproduce

  • In Admin, navigate to Stores → Attributes → Product
  • Create or select a dropdown attribute (e.g., "color")
  • Enable "Use in Search" and "Visible in Advanced Search" for the attribute
  • Save the attribute and reindex if necessary
  • Clear cache: bin/magento cache:clean
  • Navigate to the storefront advanced search results page with array parameters in the URL:
  • Example: /catalogsearch/advanced/result/?color[]=49,50 (where 49,50 - attr option ids)

Before: ✖️ 

Screenshot 2026-04-22 at 2 22 57 PM

After: ✔️

Screenshot 2026-04-22 at 2 25 39 PM

Builds are failed. Hence, moving this PR to Extended Testing.

Thanks.

@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Extended testing (optional) in Community Dashboard Apr 22, 2026
@engcom-Dash
Copy link
Copy Markdown
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Unit Tests

@engcom-Dash
Copy link
Copy Markdown
Contributor

A few of the functional tests are not consistent in the recent 2 builds. They are neither failing because of the PR nor part of the PR, considered to be flaky. The consistent failures are known issues, hence moving this PR to Merge in Progress.

CE
Build 1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40422/917530c783cedc3a01f185ac3c842505/Functional/allure-report-ce/index.html#categories
image

Build 2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40422/487f189487f9b1753061ffdfaf430eee/Functional/allure-report-ce/index.html#categories
image

EE
Build 1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40422/7aeb8edceca890aa02ecc2173a757fd1/Functional/allure-report-ee/index.html#categories
image

Build 2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40422/4ab086a8e0a69ec5eff5d2417d31b31c/Functional/allure-report-ee/index.html#categories
image

B2B
Build 1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40422/be53eef68be58a7b67896acf5841116a/Functional/allure-report-b2b/index.html#categories
image

Build 2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40422/d83c86f2701a5b8c4e50714c3d63d95e/Functional/allure-report-b2b/index.html#categories
image

Known Issue
TextInlineWidgetEditingSpecialCharacterTest: ACQE-9671

@engcom-Dash engcom-Dash moved this from Extended testing (optional) to Merge in Progress in Community Dashboard Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Project: Community Picked PRs upvoted by the community

Projects

Status: Merge in Progress

Development

Successfully merging this pull request may close these issues.

strpos() expects parameter 1 to be string, array given | magento/module-eav

5 participants