You are here

function file_entity_file_delete in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.file.inc \file_entity_file_delete()
  2. 7 file_entity.module \file_entity_file_delete()

Implements hook_file_delete().

File

./file_entity.file.inc, line 140
File hooks implemented by the File entity module.

Code

function file_entity_file_delete($file) {
  field_attach_delete('file', $file);

  // This is safe to call since the file's records from the usage table have
  // not yet been deleted.
  file_entity_invalidate_field_caches($file);

  // Remove file metadata.
  db_delete('file_metadata')
    ->condition('fid', $file->fid)
    ->execute();

  // Remove this file from the search index if needed.
  // This code is implemented in file entity module rather than in search
  // module because file entity is implementing search module's API, not the
  // other way around.
  if (module_exists('search')) {
    search_reindex($file->fid, 'file');
  }
}