There is a bug when using Path Filter with FileField Paths. Steps to reproduce:

  1. Configure your content type to include a CCK FileField field, and configure that field to move the file to the replacement pattern of "nodes/[nid]".
  2. Now, create a new node, and upload a file into that field.
  3. Copy and paste the URL of the uploaded file into the textarea, and save.

Upon viewing the node, the path to the file will be the path where FileField Paths temporarily stored the file, but not the destination path to which FileField Paths moved the file.

This happens because of the following nodeapi workflow:

  • The node is being saved.
  • During the "presave" operation, FileField Paths flags certain files to be moved (but doesn't actually move them).
  • Next, also during the "presave" operation, Path Filter internalizes the URL references in the node body (in this case, the temporary paths for the uploaded files).
  • Finally, FileField Paths moves the flagged files in the "insert" and "update" operations.

How do we fix this? It would be nice if the two modules could talk. FileField Paths moves the files in the "insert" and "update" operations, and there invokes a hook_filefield_paths_process_file() function—perhaps a pathfilter_filefield_paths_process_file() function which could update the path references in the node body?

CommentFileSizeAuthor
#5 pathfilter.inc2.07 KBdeciphered

Comments

mrfelton’s picture

If I understand you correctly, is that you are attempting to attach a file to a node using filefield, and reference that uploaded file within your node body all in one go - but your reference ends up pointing to some temporary storage location of the file, instead of it's final location, which doesn't actually come into existence until you save the node and the file is moved from this temporary to it's final location, as dictated by filefield_paths.

I don't really see what that has to do with pathfilter... Surely the same would be true even without pathfilter enabled?

geerlingguy’s picture

I would like this functionality as well - it seems that Joel is saying you could include a function that grabs the file path from hook_filefield_paths_process_file() after the node insert, and updates it in the node body... do you think that would be possible?

joelstein’s picture

I posted a similar issue in the FileField Paths issue queue (#655782: Compatibility with Path Filter module), since it is not yet clear where the best solution lies.

deciphered’s picture

Actually FileField Paths will correct references to the temporary file path in the Node Body during insert/update.
There where a couple issues with this functionality in FFP 1.3 and it has been vastly improved in the current development build.

Either way, that has nothing to do with Path Filter. If you are wanting to reference 'file:original/path/file.ext' before you save the node and have it updated to 'file:new/path/file.ext', then either one of the modules will have to do the work using a simple implementation of hook_filefield_paths_process_file().

If I where to do the work in FileField Paths it would be done on the behalf of Path Filter, creating a pathfilter.inc with a pathfilter_filefield_paths_process_file() function, so only one of the modules could/should do it.

Thoughts would be appreciated.

Cheers,
Deciphered.

deciphered’s picture

StatusFileSize
new2.07 KB

I just knocked up a quick function that fixes this issue. It was from code from FFP 1.x-dev. Could be optimized a bit, but works as is for the time being.

Either take the function out of the attached file and put it in pathfilter.module, or save the file into filefield_paths/modules (renamed to pathfilter.inc).

Let me know how you go, and would love a response from the Path Filter dev to see how you would like to proceed.

Cheers,
Deciphered.

geerlingguy’s picture

Status: Active » Needs review

Awesome, and thanks for the quick response, Deciphered! Glad to see this will be implemented, in one of the modules or the other (I hope!).

mrfelton’s picture

I'm happy to commit this into pathfilter, providing I get a several positive responses from the patch. I'm too busy to test this myself right now, but should be able to in a couple of weeks or so.

joelstein’s picture

Thanks for the quick patch!

I put the include file in my filefield_paths/modules folder, and it works. I recommend that solution, because the function will only get loaded if both the modules are installed. I'll make a note in the filefield_paths ticket about it.

deciphered’s picture

Project: Path Filter » File (Field) Paths
Version: 6.x-2.0-beta3 » 6.x-1.x-dev

@joelstein

That's fine with me, I wanted to optimize the code anyway, which would require more work on FileField Paths anyway.

Moving this issue to FileField Paths.
Should hopefully commit the fix within 24 hours.

Cheers,
Deciphered.

deciphered’s picture

Title: Compatibility with FileField Paths module » Compatibility with Path Filter module
deciphered’s picture

Status: Needs review » Fixed

Committed to DRUPAL-6--1.

Cheers,
Deciphered.

Status: Fixed » Closed (fixed)

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