fix: null-coalesce getFacets() to prevent TypeError on special char search terms#394
Open
ahuininga-orisha wants to merge 1 commit into
Open
fix: null-coalesce getFacets() to prevent TypeError on special char search terms#394ahuininga-orisha wants to merge 1 commit into
ahuininga-orisha wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a customer searches for certain characters — such as
0,-,",<,&,[,], or!— the Tweakwise search response may returnnullfor the facets list. This caused a fatal PHPTypeErroron the search results page, showing an error instead of results.The fix adds a null-coalescing fallback so that when no facets are returned, an empty array is used instead. The rest of the filter initialisation continues normally, resulting in a search results page with no filters — rather than a crash.
Changes
Model/Catalog/Layer/FilterList/Tweakwise.phpgetFacets()to[]to preventTypeErrorwhen API returns no facetsScenario 1 — Search with
0as queryq=0(e.g./catalogsearch/result/?q=0).Scenario 2 — Search with special characters
-,",<,&,[,],!.TypeError.Scenario 3 — Normal search still works