Display anywhere facet does not check if source is available

Created on 26 September 2022, about 2 years ago
Updated 13 April 2024, 6 months ago

Problem/Motivation

Having an enabled facet block that is set to be displayed on any page does not check that the search is (still) available. For example if it's been disabled. Search API itself shows a nice "Cannot search on a disabled index". Facet API throws a fatal:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "search_api:views_embed__view__display" plugin does not exist. Valid plugin IDs for Drupal\facets\FacetSource\FacetSourcePluginManager are: in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).                                                                                    
                                                                                                                                                                                                                    
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('search_api:views_embed__view__display') (Line: 16)                                                                                                          
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('search_api:views_embed__view__display', Array) (Line: 83)                                                                                              
Drupal\Component\Plugin\PluginManagerBase->createInstance('search_api:views_embed__view__display') (Line: 463)                                                                                                      
Drupal\facets\FacetManager\DefaultFacetManager->updateResults('search_api:views_embed__view__display') (Line: 250)                                                                                                  
Drupal\facets\FacetManager\DefaultFacetManager->processFacets('search_api:views_embed__view__display') (Line: 327)                                                                                                  
Drupal\facets\FacetManager\DefaultFacetManager->processBuild(Object) (Line: 387)                                                                                                                                    
Drupal\facets\FacetManager\DefaultFacetManager->build(Object) (Line: 90)                                                                                                                                            
Drupal\facets\Plugin\Block\FacetBlock->build() (Line: 171) 

Steps to reproduce

  • Create a search, view
  • Create a facet. Configure the to display on all pages.
  • Enable the block to be displayed.
  • Then disable the search.
  • Visit a page where the block would be rendered.

Proposed resolution

I think it could be as simple as https://git.drupalcode.org/issue/facets-3311856/-/commit/765d5ef4228906c...
$facet->getFacetSource() is needed no matter if it is on the page itself or elsewhere. It isn't returned if the index isn't available for whatever reason.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands ekes

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024