Synonyms processor throws an error after changing index server

Created on 8 September 2023, over 1 year ago

Problem/Motivation

We have a synonyms processor that works only on Meilisearch backends. When using an index connected to Meilisearch backend we can enable this processor. However when this processor is enabled and we edit the index and disconnect it (or use another backend), visiting "Processors" tab throws the following error.

Error: Call to a member function getBackend() on null in Drupal\search_api_meilisearch\Plugin\search_api\processor\Synonyms::supportsIndex() (line 145 of modules/contrib/search_api_meilisearch/src/Plugin/search_api/processor/Synonyms.php).
Drupal\search_api_meilisearch\Plugin\search_api\processor\Synonyms::supportsIndex(Object)
call_user_func(Array, Object) (Line: 371)
Drupal\search_api\Form\IndexProcessorsForm->getAllProcessors() (Line: 103)
Drupal\search_api\Form\IndexProcessorsForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('search_api_index_processors_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  • Create an index and configure it to use Meilisearch backend server
  • Go to "Processors" page and enable "Synonyms" processor
  • Save the index
  • Edit the index and select "- No server -" from the server selection field then save
  • Visit the "Processors" page and the error in the description appears

Proposed resolution

Add a check if server exists in supportsIndex method of the processor

Remaining tasks

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇸🇮Slovenia bcizej

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

Comments & Activities

Production build 0.71.5 2024