You are here

function sbp_attach_node_delete in Search by Page 7

Implements hook_node_delete().

When a node is deleted, remove its attached files from the search index.

File

./sbp_attach.module, line 573
Module file for Search by Page Attachments, a sub-module for Search by Page.

Code

function sbp_attach_node_delete($node) {

  // Find the sbp_attach IDs in our database associated with this node ID.
  $res = db_query("SELECT sbpaid FROM {sbpa_attachments} WHERE objtype = 'node' AND objid = :nid", array(
    ':nid' => $node->nid,
  ))
    ->fetchCol();
  foreach ($res as $id) {
    search_by_page_force_remove('sbp_attach', $id);
  }
}