You are here

public function SearchApiAbstractDataSourceController::trackItemDelete in Search API 7

Stops tracking the index status for the given items on the given indexes.

Parameters

array $item_ids: The IDs of the removed items.

SearchApiIndex[] $indexes: The indexes for which the deletions should be tracked.

Return value

SearchApiIndex[]|null All indexes for which any items were deleted; or NULL if items were deleted for all of them.

Throws

SearchApiDataSourceException If any error state was encountered.

Overrides SearchApiDataSourceControllerInterface::trackItemDelete

1 method overrides SearchApiAbstractDataSourceController::trackItemDelete()
SearchApiExternalDataSourceController::trackItemDelete in includes/datasource_external.inc
Stop tracking the index status for the given items on the given indexes.

File

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

Class

SearchApiAbstractDataSourceController
Provides a default base class for datasource controllers.

Code

public function trackItemDelete(array $item_ids, array $indexes) {
  if (!$this->table || $item_ids === array()) {
    return NULL;
  }
  $ret = array();
  foreach ($indexes as $index) {
    $this
      ->checkIndex($index);
    $delete = db_delete($this->table)
      ->condition($this->indexIdColumn, $index->id)
      ->condition($this->itemIdColumn, $item_ids, 'IN');
    try {
      if ($delete
        ->execute()) {
        $ret[] = $index;
      }
    } 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 deleted items (IDs: @item_ids) on index %index: !message in %function (line %line of %file).', $vars);
    }
  }
  return $ret;
}