Fix Index::setProcessors() to not assume $processors is keyed by plugin ID

Created on 17 August 2025, 3 days ago

The $processors argument of \Drupal\search_api\IndexInterface::setProcessors() is documented as follows:

  /**
   * @param \Drupal\search_api\Processor\ProcessorInterface[] $processors
   *   An array of processors.
   */

Specifically, we do not require it to be keyed by plugin ID. However, Index::setProcessors() looks like this:

  public function setProcessors(array $processors) {
    $this->processorInstances = $processors;
    return $this;
  }

Since the rest of the code assumes $this->processorInstances is keyed by plugin ID, this relies on the undocumented assumption that $processors will always be keyed by plugin ID.

We actually fixed the same thing for setDatasources() back in 🐛 Fix contract of IndexInterface::setDatasources() Active . However, seems we forgot to check whether other setters are also affected. (setFields() also assumes that $fields is keyed correctly, but there it is actually specified in the contract so it should be fine.)

🐛 Bug report
Status

Active

Version

1.0

Component

General code

Created by

🇦🇹Austria drunken monkey Vienna, Austria

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