Skip to content

Commit

Permalink
Issue #3396152 by mkalkbrenner, neclimdul: PostCreateIndexDocumentsEv…
Browse files Browse the repository at this point in the history
…ent misses the index
  • Loading branch information
Markus Kalkbrenner authored and mkalkbrenner committed Oct 24, 2023
1 parent 4fccfb5 commit 2f2ebec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Event/AbstractSearchApiItemSolariumDocumentEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Drupal\search_api_solr\Event;

use Drupal\Component\EventDispatcher\Event;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Item\ItemInterface;
use Solarium\Core\Query\DocumentInterface;

/**
* Search API Solr event base class.
*/
abstract class AbstractSearchApiItemSolariumDocumentEvent extends Event {
abstract class AbstractSearchApiItemSolariumDocumentEvent extends AbstractIndexAwareEvent {

/**
* The search_api query.
Expand All @@ -33,7 +33,8 @@ abstract class AbstractSearchApiItemSolariumDocumentEvent extends Event {
* @param \Solarium\Core\Query\DocumentInterface $solarium_document
* The solarium document.
*/
public function __construct(ItemInterface $search_api_item, DocumentInterface $solarium_document) {
public function __construct(ItemInterface $search_api_item, DocumentInterface $solarium_document, IndexInterface $index) {
parent::__construct($index);
$this->searchApiItem = $search_api_item;
$this->solariumDocument = $solarium_document;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/search_api/backend/SearchApiSolrBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ public function getDocuments(IndexInterface $index, array $items, UpdateQuery $u
$boost_terms = [];

/** @var \Solarium\QueryType\Update\Query\Document $doc */
$event = new PreCreateIndexDocumentEvent($item, $update_query->createDocument());
$event = new PreCreateIndexDocumentEvent($item, $update_query->createDocument(), $index);
$this->dispatch($event);
$doc = $event->getSolariumDocument();

Expand Down Expand Up @@ -1440,7 +1440,7 @@ public function getDocuments(IndexInterface $index, array $items, UpdateQuery $u
}

if ($doc) {
$event = new PostCreateIndexDocumentEvent($item, $doc);
$event = new PostCreateIndexDocumentEvent($item, $doc, $index);
$this->dispatch($event);
$documents[] = $event->getSolariumDocument();
}
Expand Down

0 comments on commit 2f2ebec

Please sign in to comment.