Posted by adamo on March 8, 2010 at 7:55pm
5 followers
| Project: | FileField |
| Version: | 6.x-3.3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Currently FileField is only invoking the FileField module to check for file references when validating the contents of a Filefield. So, if a file isn't already used in a FileField, you can't add it to a FileField. If it did module_invoke_all to check for any file references from any module, people would be able to use files they uploaded by other means. FileField already uses module_invoke_all() when checking for file references before deleting a file, so it would only delete files that were no longer referenced by anything else.
See #441280: Editing node causes Referencing to the file used in the field is not allowed for discussion related to this issue.
Comments
#1
+1 and thanks very much Adamo for pushing this along...and thanks quicksketch for following up with the code.
Now waiting for a fix that's better than the (much appreciated) hack at http://drupal.org/node/441280#30
#2
Here's the basic idea implemented in a patch. This introduces an implementation of hook_file_delete() for FileField, since it is necessary if a file were uploaded by FileField but then force-deleted by some other module (like IMCE). I haven't actually tested this in any capacity, just an idea of how we should go about this.
#3
subing
As per Adamo's original post, I have the same use case with IMCE as all purpose file/image-browser in conjunction with File Field + File Field Sources.
#4
This problem was a bit more complicated than I thought, but the patch in #2 had the right idea. There were a few caveats where FileField shouldn't be calling node_save() multiple times when a node is saved and file has been removed. Likewise, FileField should not be attempting to delete a file multiple times if field_file_delete($file, TRUE) is called to force the deletion of a file.
I've committed this patch so that we can get it in as part of the 3.4 release.
#5
Automatically closed -- issue fixed for 2 weeks with no activity.