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 #3483584: Fix Index::setDatasources() to match its contract. 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.)

Issue fork search_api-3541714

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Status: Active » Needs review

Should be fixed in this MR.

drunken monkey’s picture

Status: Needs review » Fixed

Merged.

  • drunken monkey committed 64f0686d on 8.x-1.x
    [#3541714] fix: Fixed Index::setProcessors() to not assume $processors...
mansidrupalbliss’s picture

Thank you Thomas for fixing this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.