You are here

function apachesolr_nodeapi_mass_delete in Apache Solr Search 5.2

Same name and namespace in other branches
  1. 6 apachesolr.index.inc \apachesolr_nodeapi_mass_delete()
  2. 6.2 apachesolr.index.inc \apachesolr_nodeapi_mass_delete()
1 call to apachesolr_nodeapi_mass_delete()
apachesolr_cron_check_node_table in ./apachesolr.index.inc
hook_cron() helper to try to make {apachesolr_search_node} consistent with {node}.

File

./apachesolr.index.inc, line 334
Functions used when indexing content to Apache Solr.

Code

function apachesolr_nodeapi_mass_delete($nodes) {
  if (empty($nodes)) {
    return TRUE;
  }
  $ids = array();
  $nids = array();
  foreach ($nodes as $node) {
    $ids[] = apachesolr_document_id($node->nid);
    $nids[] = $node->nid;
  }
  try {
    $solr = apachesolr_get_solr();
    $solr
      ->deleteByMultipleIds($ids);
    apachesolr_index_updated($time);

    // There was no exception, so update the table.
    db_query("DELETE FROM {apachesolr_search_node} WHERE nid  IN (" . db_placeholders($nids) . ")", $nids);
    return TRUE;
  } catch (Exception $e) {
    watchdog('Apache Solr', nl2br(check_plain($e
      ->getMessage())), WATCHDOG_ERROR);
    return FALSE;
  }
}