Error when adding new display to view

Created on 11 February 2025, about 2 months ago

Problem/Motivation

When adding a new display to an existing view that uses facet filters (Facets 3.x) in Drupal 10, an error message appears:
Drupal\facets\Exception\Exception: No facet source defined for facet. in Drupal\facets\Entity\Facet->getQueryType() (line 494 of XXX/web/modules/contrib/facets/src/Entity/Facet.php).
The page display requires a path, but due to the error, the configuration tab to edit the path is inaccessible, and can neither be edited or the view be saved.

Steps to reproduce

  1. Create a new view (using, for example, the search_api_index_inhalte base table) and add facet filters. Confirm that the view and its facets work correctly.
  2. Add a new display to the view. When adding a display, notice that the view throws the “No facet source defined for facet” error.
  3. After reloading the page, the new views display is created but the tab for configuration remains inaccessible until beeing saved. In case of display type page saving the view is not possible because path is required.
  4. If the new display is added as a Block, the view can be saved, and you are able to later access and edit the display without issues.

Proposed resolution

It appears that new Views displays are not properly linked to a valid facet source upon creation, leading to this error. The likely cause is that during the creation process , the facet source for displays is either not registered or not accessible in the configuration form. A patch is needed to ensure that when a new Views display is added, its facet source is properly defined and registered so that the configuration form (including the required path field) can be accessed.

Remaining tasks

  • Investigate the derivation process for facet sources in the context of Views displays in Facets 3.x.
  • Ensure that upon creation of a new Views display, the facet source is properly registered and made available in the facet configuration UI.

User interface changes

  • No direct UI changes are expected. However, after the fix, the configuration tab for newly created Views displays should be accessible, allowing the user to set the required settings e.g. path.

API changes

  • The patch might involve changes to the plugin manager for facets or adjustments to the SearchApiDisplayDeriver to ensure that new Views displays have a proper facet source identifier.

Data model changes

  • No changes to the data model are expected.
🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇩🇪Germany semanthis

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024