This isn't really a bug caused by FileField, but we can help prevent it from happening. If a widget is configured to upload to the a directory that begins with the same path as the files directory, ImageCache cannot properly work with it. The problem doesn't exist with just ImageCache though, I'm sure it affects other modules as well.

To reproduce:
- Set your file system directory to "files" (the Drupal 5 default).
- Add a new file field and give it the upload path "files/[uid]".
- Create a new node and upload a file into the new field. The file will be uploaded to "files/files/1/name-of-file.png".
- Now try to add an ImageCache formatter to that field, you'll find it doesn't work.

This is because ImageCache uses the core function "file_create_path()" to make a path the original file. The trouble is when a path like "files/1/name-of-file.png" comes in, it's already considered to be a valid file path since it begins with "files". So ImageCache looks for the file at "files/1/name-of-file.png" instead of "files/files/1/name-of-file.png". Since it can't find the file it returns a 404.

The only solution to this that I can think of is to simply prevent users from using their file directory path when setting up FileFields. This has the effect of forcing users to change their file path if they've already setup a field like this, though changing the file path doesn't have any negative effect (other than having the files split between two directories).

Comments

StatusFileSize
new1.43 KB

Oops that patch contains fixes for another issue as well. This one contains only the necessary changes for this problem.

Status:Needs review» Fixed

Committed, hopefully this stop preventable problems with ImageCache.

Status:Fixed» Closed (fixed)

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