I am trying to create a drupal file control system.
File field using some of the other contributed modules looks like a good way to build the system...however...

I am unsure how file field handles revisions of a file.
When the node is edited and a file in a file field replaced can you still access the older file? And how is this indicated as an older file?
Is file field secure enough to ensure sensitive business documentation will not be publicly available?

If this is not the case then is there some system that can provide all of the requirements of a document control system?

#2 filefield_references.patch2.63 KBquicksketch


lifepillar’s picture

Component:Documentation» Code
Category:support» bug
Priority:Normal» Critical

I have just tried the following (6.x-3.0-alpha7 with PostgreSQL):

1) Create a new content type named "Document";
2) Add a FileField to Document;
3) Create a Document node, upload a file and save;
4) Edit the same Document node, remove/replace the file, check "Create new revision" and save.

The first uploaded file is deleted from disk and from the "files" table. Of course, reverting to the previous revision will recover the node, but not its attachment.

Somewhere else I have read that this should have been fixed around 6.x-2.0… I turn this into a bug report and set priority to "critical", since the bug can cause loss of data.

quicksketch’s picture

new2.63 KB

Looks like FileField must have introduced a regression bug at one point. All the revision support code is in place, but it doesn't operate properly. This patch corrects a nasty typo which pretty much prevented FileField from counting any references.

After applying this patch, I ran through the following workflow successfully:

1. Created a new node with a file uploaded.
2. Edited the node and created a new revision, replacing the file with a different one.
3. Both revisions still have the files intact.
4. Reverted back to the first version of the node.
5. All three revisions still have the files intact.
6. Deleted the original revision of the node.
7. Both revisions still have files intact.
8. Reverted back to the second revision of the node, then deleted the previous revision.
9. The original file was deleted (since all revisions containing it are now removed), both the remaining revisions reference the same file.

So I think this patch fixes all the problems. Please test and let me know if you can find any other problems.

lifepillar’s picture

I have applied your patch. It outputs:

patching file filefield.module
Hunk #1 succeeded at 514 (offset -35 lines).
patching file filefield_field.inc
Hunk #1 FAILED at 122.
1 out of 1 hunk FAILED -- saving rejects to file filefield_field.inc.rej
patching file field_file.inc

but I confirm that it fixes the problem.

quicksketch’s picture

Status:Active» Reviewed & tested by the community

Awesome thanks. Yeah sorry about the offsets being way off, I'm in the middle of many, many changes to FileField.

lifepillar’s picture

Status:Reviewed & tested by the community» Active

Mmh, I have added ImageField and I am back to the same problem: if I create a new revision by replacing an attachment, the original picture is deleted.

Btw, weren't revisions supposed to be dealt with at the CCK level (http://drupal.org/node/340768)? Or is each CCK module supposed to take care of it?

quicksketch’s picture

Status:Active» Reviewed & tested by the community

Yes, currently ImageField revision support is also broken. :P

ImageField revisions DO work if you select "File" as the type and "Image" as the widget, but not if the type and widget are both "Image". I'm working on an upgrade path to remove the "Image" type entirely and make it only a widget, which will fix problems like this.

So I think these problems are separate, this patch fixes FileField but not ImageField.

quicksketch’s picture

Marked ImageField issue as duplicate: #320494: Images lost on revision deletion.

Combined with #397578: Uncouple ImageField from FileField Custom Hooks, this patch also fixes ImageField.

quicksketch’s picture

Title:File Field - Handling Revisions for document control» Properly Handle Revisions for document control
Status:Reviewed & tested by the community» Fixed

I committed #397578: Uncouple ImageField from FileField Custom Hooks and this patch, so revisions should now be working in FileField and ImageField. I'm working on getting out a beta release as soon as possible with all the new fixes.

enginpost’s picture

Could someone help me understand how to apply the patch in this thread. I am on a Windows machine, but I could be on a mac if that works better. I just need to learn how to patch this thing!!!

quicksketch’s picture


But really, I'd suggest just grabbing the 3.x development version (click "View all releases" from the project page) which already has this patch applied.

Status:Fixed» Closed (fixed)

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