Skip to content

fix: null-coalesce getFacets() to prevent TypeError on special char search terms#394

Open
ahuininga-orisha wants to merge 1 commit into
developfrom
fix/209808-special-chars-search-term-error
Open

fix: null-coalesce getFacets() to prevent TypeError on special char search terms#394
ahuininga-orisha wants to merge 1 commit into
developfrom
fix/209808-special-chars-search-term-error

Conversation

@ahuininga-orisha

Copy link
Copy Markdown
Collaborator

When a customer searches for certain characters — such as 0, -, ", <, &, [, ], or ! — the Tweakwise search response may return null for the facets list. This caused a fatal PHP TypeError on 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

File What changed
Model/Catalog/Layer/FilterList/Tweakwise.php Null-coalesce getFacets() to [] to prevent TypeError when API returns no facets

Scenario 1 — Search with 0 as query

  1. Navigate to the search results page with query q=0 (e.g. /catalogsearch/result/?q=0).
  2. Verify the page loads without a PHP error or exception.
  3. Verify that products (if any match) or an empty results state is shown — no 500 error.

Scenario 2 — Search with special characters

  1. Search for each of the following terms one at a time: -, ", <, &, [, ], !.
  2. For each term, verify the search results page loads without a PHP TypeError.
  3. Verify layered navigation renders (possibly with no filters if none are returned).

Scenario 3 — Normal search still works

  1. Search for a regular product keyword (e.g. a product name or category term).
  2. Verify search results load correctly with filters/facets displayed as expected.
  3. Confirm no regression in filter behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant