Impossible to delete a server entity when Solr server is not available

Created on 7 July 2025, 6 days ago

Description

Deleting an existing SearchAPI server config object is not possible if the connected Solr server is not available.

We ran into this error after deleting the configuration for an existing SearchAPI server (migrating to a different search provider). When importing the configuration to prepare our test setup in our CI the specific pipeline fails because of a SearchAPI exception thrown in in SearchApiSolrBackend::deleteAllIndexItems()
The functions calls $connector->update(); without checking first if the connection is available (in our CI environment we don't have a Solr server, so it is not).

Exception trace (excerpt):

  #11 /builds/[...]/docroot/modules/contrib/search_api_solr/src/SolrConnector/SolrConnectorPluginBase.  
  php(1067): Solarium\Core\Client\Client->execute(Object(Solarium\QueryType\Update\Query\Query), Object(Drupal\acquia_search\Client\Solarium\Endpoint))   
  #12 /builds/[...]/docroot/modules/contrib/search_api_solr/src/SolrConnector/SolrConnectorPluginBase.  
  php(1009): Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase->execute(Object(Solarium\QueryType\Update\Query\Query), Object(Drupal\acquia_search\Client\Solarium\Endpoint))                                             
  #13 /builds/[...]/docroot  
/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php(1524): Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase->update(Object(Solarium\QueryType\Update\Query\Query), Object(Drupal\acquia_search\Client\Solarium\Endpoint))                                     
  #14 /builds/[...]/docroot/modules/contrib/search_api/src/Entity/Server.php(453): Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->deleteAllIndexItems(Object(Drupal\search_api_solr\Entity\Index))                                    
  #15 /builds/[...]/docroot/modules/contrib/search_api/src/Backend/BackendPluginBase.php(225): Drupal\search_api\Entity\Server->deleteAllItems()                                   
  #16 /builds/[...]/docroot/modules/contrib/search_api/src/Entity/Server.php(579): Drupal\search_api\Backend\BackendPluginBase->preDelete()                                        
  #17 /builds/[...]/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(450): Drupal\search_api\Entity\Server::preDelete(Object(Drupal\search_api\Entity\SearchApiConfigEntityStorage), Array)          

Setup

  • Solr version: 9
  • Drupal Core version: 10.5.1
  • Search API version: 1.38.0
  • Search API Solr version: 4.3.10
  • Configured Solr Connector:
      connector: standard
      connector_config:
        scheme: http
        host: solr
        port: 8983
        path: /
        core: search
        timeout: 5
        index_timeout: 5
        optimize_timeout: 10
        finalize_timeout: 30
        skip_schema_check: false
        solr_version: ''
        http_method: AUTO
        commit_within: 1000
        jmx: false
        jts: false
        solr_install_dir: ''
    

How to fix

In delete() and deleteAllIndexItems we need to call isAvailable() first to ensure the Solr instance is available.

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇩🇪Germany stborchert

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

Comments & Activities

Production build 0.71.5 2024