summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Haug2010-12-06 06:32:12 +0000
committerNathan Haug2010-12-06 06:32:12 +0000
commit3a57bc8263d7fca30a78c182034b8e8c8ea09836 (patch)
tree5b07666f287dd11d8dd42e146c267894d3990f2a
parentef179f8adb8e3c6bb063a51e954bfff80d02e1df (diff)
#433028 by mcarbone: Files from previous revisions (but not in latest one) are not removed on node delete.
-rw-r--r--filefield_field.inc11
1 files changed, 11 insertions, 0 deletions
diff --git a/filefield_field.inc b/filefield_field.inc
index 37d2329..f7285b1 100644
--- a/filefield_field.inc
+++ b/filefield_field.inc
@@ -227,6 +227,17 @@ function filefield_field_delete($node, $field, &$items, $teaser, $page) {
$item['delete_nid'] = $node->nid;
filefield_field_delete_file($item, $field);
}
+
+ // Delete all the remaining items present only in older revisions.
+ $db_info = content_database_info($field);
+ $result = db_query('SELECT vid, f.* FROM {' . $db_info['table'] . '} t INNER JOIN {files} f ON t.' . $db_info['columns']['fid']['column'] . ' = f.fid WHERE nid = %d AND vid != %d', $node->nid, $node->vid);
+ while ($item = db_fetch_array($result)) {
+ if (isset($item['fid'])) {
+ $item['field_name'] = $field['field_name'];
+ $item['delete_vid'] = $item['vid'];
+ filefield_field_delete_file($item, $field);
+ }
+ }
}
/**