This isn't so much a bug report as an inquiry. But in the imce.page.inc in the imce_file_register() I see that when the file_usage_add function is called instead of passing in the node ID it's passing the file ID. So when I look in the file_usage table I see the fid and id are the same. So essentially this record is not attached to the node table. I notice this only happens when an image is added through the body field. Why not store the node ID/
If anyone could answer this it would be greatly appreciated.
function imce_file_register($file) {
if (!db_query("SELECT 1 FROM {file_usage} WHERE module = 'imce' AND fid = :fid", array(':fid' => $file->fid))->fetchField()) {
file_usage_add($file, 'imce', 'file', $file->fid);
}
}
Comments
Comment #2
smustgrave commentedI found the reason why, I see that as soon as a user uploads a file through the image browser in the body field it is added to the file_usage table. And in some cases the node may be brand new so it wouldn't have a nid yet until it was saved. Unfortunately when you delete the node though since the file is not attached to the node table it is never deleted and files kept stacking. Possible fix would be to update the file_usage record when the node is saved or wait until the node is saved before saving in the table.
Comment #3
smustgrave commentedComment #4
thallesSo, this looks me solved!
Thanks @smustgrave for your jobs!
Comment #5
thalles