You are here

function apachesolr_nodeapi_mass_delete in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5.2 apachesolr.index.inc \apachesolr_nodeapi_mass_delete()
  2. 6 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 411
Functions used when indexing content to Apache Solr.

Code

function apachesolr_nodeapi_mass_delete($nodes) {
  if (empty($nodes)) {
    return TRUE;
  }
  if (variable_get('apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) {
    return TRUE;
  }
  $ids = array();
  $nids = array();
  foreach ($nodes as $node) {
    $ids[] = apachesolr_document_id($node->nid);
    $nids[] = $node->nid;
  }
  $time = time();
  try {
    $solr = apachesolr_get_solr();
    $solr
      ->deleteByMultipleIds($ids);
    apachesolr_index_set_last_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())), NULL, WATCHDOG_ERROR);
    return FALSE;
  }
}