You are here

public function SearchApiAbstractDataSourceController::trackItemIndexed in Search API 7

Sets the tracking status of the given items to "indexed".

Parameters

array $item_ids: The IDs of the indexed items.

SearchApiIndex $index: The index on which the items were indexed.

Throws

SearchApiDataSourceException If any error state was encountered.

Overrides SearchApiDataSourceControllerInterface::trackItemIndexed

1 method overrides SearchApiAbstractDataSourceController::trackItemIndexed()
SearchApiExternalDataSourceController::trackItemIndexed in includes/datasource_external.inc
Set the tracking status of the given items to "indexed".

File

includes/datasource.inc, line 730
Contains the SearchApiDataSourceControllerInterface as well as a default base class.

Class

SearchApiAbstractDataSourceController
Provides a default base class for datasource controllers.

Code

public function trackItemIndexed(array $item_ids, SearchApiIndex $index) {
  if (!$this->table || $item_ids === array()) {
    return;
  }
  $this
    ->checkIndex($index);
  try {
    db_update($this->table)
      ->fields(array(
      $this->changedColumn => 0,
    ))
      ->condition($this->itemIdColumn, $item_ids, 'IN')
      ->condition($this->indexIdColumn, $index->id)
      ->execute();
  } catch (Exception $e) {
    $tmp = array_slice($item_ids, 0, 10);
    $item_ids_string = '"' . implode('", "', $tmp) . '"';
    $vars = array(
      '%index' => $index->name,
      '@item_ids' => $item_ids_string,
    );
    watchdog_exception('search_api', $e, '%type while tracking indexed items (IDs: @item_ids) on index %index: !message in %function (line %line of %file).', $vars);
  }
}