You are here

function search_api_index_specific_items_delayed in Search API 7

Queues items for indexing at the end of the page request.

Parameters

SearchApiIndex $index: The index on which items should be indexed.

array $ids: The IDs of the items which should be indexed.

Return value

array The current contents of the queue, as a reference.

See also

search_api_index_specific_items()

_search_api_index_queued_items()

4 calls to search_api_index_specific_items_delayed()
search_api_track_item_change_for_indexes in ./search_api.module
Marks the items with the specified IDs as "dirty" for the given indexes.
search_api_track_item_insert in ./search_api.module
Inserts new unindexed items for all indexes on the specified type.
_search_api_index_queued_items in ./search_api.module
Shutdown function which indexes all queued items, if any.
_search_api_rules_action_index in ./search_api.rules.inc
Rules action for indexing an item.

File

./search_api.module, line 1838
Provides a flexible framework for implementing search services.

Code

function &search_api_index_specific_items_delayed(SearchApiIndex $index = NULL, array $ids = array()) {

  // We cannot use drupal_static() here because the static cache is reset during
  // batch processing, which breaks batch handling.
  static $queue = array();
  static $registered = FALSE;

  // Only register the shutdown function once.
  if (empty($registered)) {
    drupal_register_shutdown_function('_search_api_index_queued_items');
    $registered = TRUE;
  }

  // Allow for empty call to just retrieve the queue.
  if ($index && $ids) {
    $index_id = $index->machine_name;
    $queue += array(
      $index_id => array(),
    );
    $queue[$index_id] += drupal_map_assoc($ids);
  }
  return $queue;
}