Download & Extend

Function filefield_filefield_paths_get_fields prevents usage outside of the Form API

Project:File (Field) Paths
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

revision 1.1.2.28 made a change to the filefield_paths_get_fields function that assumes the module is being used only when submitting forms.

The code change is breaking programmatic file field creation, for example using imagecache programmatically to scale/crop images as used here: http://happypixels.net/blog/triggering-creation-imagecache-derivatives-p...

Is there a reason why the filefield_filefield_paths_get_fields function in modules/filefield.inc checks that a form_id is set on the $node param?

if (is_object($node) && $node->form_id == $node->type .'_node_form')

Couldn't the if stmt simply say:

if (is_object($node))

The previous implementation didn't check that a form_id was present and matched the content type name, but simply started iterating through the content type fields.

Comments

#1

My apologies, I am aware of this issue as it breaks File Aliases.

Unfortunately the reason it was done that way was so that certain module compatibility wouldn't get mixed up, like Upload module files being identified as Comment Upload module files.

I will have a fix for this issue as soon as humanly possible.

Out of curiosity, did you run into this issue with File Aliases, or have you built another module that integrates with FileField Paths? Would be very interested in hearing how you are using FileField Paths.

Cheers,
Deciphered.

#2

I have a custom module that is creating an imagefield using ImageCache programmatically the way described on the link in my first comment. The imagefield field on my content type is using filefield paths to tokenize the filepath.

#3

Hi pixelantegroup,

I've attached the latest internal dev version for you to test out. Haven't looked at it since I got side-tracked working on a new module, but I had been testing it and I'm pretty sure I had fixed the main issue without and weeded out some of the other issues that the main issue was introduced to prevent.

I wouldn't specifically suggest deploying it on a production site, but testing would be appreciated and help speed up the process for the 1.4 bug fix release.

Cheers,
Deciphered.

AttachmentSize
filefield_paths.zip 32.04 KB

#4

I'll give it a go either later today or tomorrow and let you know how it goes. Thanks a lot!

#5

Status:active» fixed

Fix committed to DRUPAL-6--1 and DRUPAL-5.

Cheers,
Deciphered.

#6

Status:fixed» closed (fixed)