Return data source ids in Index::getDatasourceIds() without initalizing plugins

Created on 16 April 2025, 26 days ago

Problem/Motivation

An infinite loop occurs when a custom datasource deriver interacts with Search API Solr's dynamic data types.
The loop is triggered by calling $this->entityFieldManager->getFieldMapByFieldType() while
search_api_solr is enabled, which leads to recursive datasource plugin loading.

Steps to Reproduce:

  1. Enable both search_api and search_api_solr.
  2. Implement a datasource deriver that uses $this->entityFieldManager->getFieldMapByFieldType().
  3. Observe the infinite recursion caused by:
    • Custom deriver → getFieldMapByFieldType()
    • Triggers SolrDocumentDeriver::getDerivativeDefinitions()
    • Calls Utility::hasIndexSolrDatasources()Index::getDatasourceIds()
    • Reloads datasource plugins, re-triggering the custom deriver

Fixing this could also lead to a potential performance improvement.

Steps to reproduce

Proposed resolution

array_keys($this->datasource_settings) could be used to return the data source plugin ids with initialization - this value is also used by \Drupal\search_api\Entity\Index::getDatasources() which leads to data source plugin initializations.

Remaining tasks

🐛 Bug report
Status

Active

Version

1.0

Component

General code

Created by

🇭🇺Hungary mxr576 Hungary

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024