Hi,

This modules records every file, but if it gets deleted, a report would be meaningless (for these deleted files that you don't know who they are anymore).

I suggest two solutions:
- Records file name also (meaningless if you don't have the file anymore)
- hook file_delete to erase the record for that fid.

I added this to filefield_stats.module (i don't know how to create a patch):

function filefield_stats_file_delete($file) {
	drupal_set_message('object' . $file->fid);
	db_query("DELETE FROM filefield_stats WHERE fid = %d", $file->fid);
}

Comments

fietserwin’s picture

Status: Active » Fixed

For now, I added your suggestion to add a hook_file_delete:

function filefield_stats_file_delete($file) {
  db_query("DELETE FROM {filefield_stats} WHERE fid = %d", $file->fid);
}

Thus including angle brackets and without a message, that is up to filefield.

In a future release, I might add the name of the file in which case this feature should probably become optional. but that will introduce an admin settings form, etc.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.