I cant seem to figure out why this is happening...

I have a nodetype, with an imagefield. The imagefield_path for the imagefield is set to "groups/images/[nid]/[filename]"

On node/add, and uploading an image into the field, it places the image in [filesystem-path]/groups/[uid]/images/[filename]. (removing nid and palcing uid between the first 2 path parts)

Once I save the node, it places it into the correct directory, however the path string of the cck field is still [filesystem-path]/groups/[uid]/images/[filename].
so when its echoed in the node template, the image isn't there.

It's not until I save the node a 2nd time that the path string is updated and displays correctly on node/[nid].

Any suggestions?
Why is it using the uid on upload and using that path. I haven't specified that path anywhere.

this happens with both the dev and stable versions.

thanks.

Comments

loze’s picture

Status: Active » Closed (duplicate)

actually, this looks like a duplicate of http://drupal.org/node/635854
except for the [uid] issue.

loze’s picture

After further investigation, this is what I found.

1. The file path IS being stored correctly in the files table.
2. Clearing the cache, makes the correct file appear. (without having to save the node a 2nd time)

So, presumably, the temp file path is being cached for the node, on the original save.
Still cant tell whats up with that uid in the temp path though.

My question: is there a way to tell the node not to cache the field data on the initial save. (is that even a good idea?)

thanks!

loze’s picture

I was able to fix this by adding:
cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
to the 'insert' op of nodeapi, in a custom module i am using that has a low weight. (20)

so the cache clearing is executed after everything else. FFP does this on line 440 of filefield_paths.module already. so I think in my instance, its being called twice now.

Maybe consider giving FFP a heavier weight? Not sure if that would do it or not.

crosendahl’s picture

I ran into an almost identical issue (http://drupal.org/node/736680). Thanks for the insight about the weight of the module. I just changed the weight of filefield_paths in the system table of the database from '0' to '20' and it fixed my issue.
Thank you!

delapohl’s picture

Thanks, this issue was resolved in my install once I set the weight of FPP to 21 -- after that of the rules module (20). Anything lower resulted in the issue described in the original post.

abdulFarooqui’s picture

In my case I am unable to resolve this issue by setting weight high, I tried 20,21 and all the way highest than any other module. I also wrote a module to refresh cache, and gave it a higher weight, still no luck...

eliza411’s picture

I was glad to find this. I'd been happily using filefield_paths, but after the most recent batch of updates (6.19 core, filefield 3.x-3.7), this problem cropped up and changing the weight to 20 fixed it.