I am not completely sure if this is a bug in the Filefield Paths module or elsewhere, but I am experiencing some strange behavior. I am using the filefield paths module to control the upload directory for a filefield cck field. The pattern I am using to set the file path is something like:
pubs/[token1]/[token2]
so if I upload "test.pdf" it should be put in files/pubs/[token1]/[token2]/test.pdf, where the tokens are filled in from other cck fields in the node. This works, in that the file is uploaded to the intended directory.
However, after creating the node, the link to the file is incorrect. It points to "files/pubs/test.pdf" instead of the directory where the file is actually sitting. This link is fixed if I (a) edit and then re-save the node or (b) run a retroactive update.
Comment | File | Size | Author |
---|---|---|---|
#19 | filefield_clear_file_cache.patch | 531 bytes | joshuajabbour |
#18 | filefield_clear_file_cache.patch | 535 bytes | joshuajabbour |
#10 | filefield_clear_file_cache.patch | 735 bytes | hefox |
Comments
Comment #1
loze CreditAttribution: loze commentedI am having the same issue. (i think)
http://drupal.org/node/641252#comment-2300248
Comment #2
Deciphered CreditAttribution: Deciphered commentedAs FileField Paths uses node tokens which can't be populated until the file is saved, the path isn't processed until you save.
Links to the old path will also be processed upon save, however this is improved somewhat in the current development build.
Cheers,
Deciphered.
Comment #4
Agileware CreditAttribution: Agileware commentedThis issue was hard to track down due to a few issues with bad titles so
I'm fixing it up a little as it might be reasonably common.
Hopefully this title is a little clearer.
As mentioned in #641252: Strange behavior with paths on Node creation.
this issue is related to this modules weight.
If the weight of this module is changed to be after whichever module is interfering
the problem goes away.
In my case the module was uc_node_checkout, which has its weight set to 100.
To fix it I set the weight of this module to 101.
Other people have fixed it by setting the weight to 20.
It depends on what other modules you have.
So a fix for this module would be either:
1. Set the weight of this module above everything else (modules installed after this one would be another issue)
2. Make a note in the documentation and on the project page about this weight issue
Comment #5
Sera CreditAttribution: Sera commentedThe Bug is nevertheless still active for 6.x-1.4.
But I tried the recommended solution: "I just changed the weight of filefield_paths in the system table of the database from '0' to '20'".
At a very rough test it fixed my issue, but I will test it more intensively the next week.
update: Sadly the error still appears. It's hard to test as sometimes the upload is ok, sometimes not.
Comment #6
arthursk CreditAttribution: arthursk commentedFurther confirming this issue.
FileField Path does not pass the NEW filename and/or path until AFTER the node has been created, then edited and resaved
Changing the weight to 20 appears to have solved the problem, is this a safe fix?
Comment #7
Sera CreditAttribution: Sera commentedNo, sadly the issue is still active. Probably the path does appear to be correctly more often, but the filename is still not always correct. :(
Yesterday my filepath was again /system/files/ instead of /system/files/[token]/[token]/
Thus changing the weight is not our patch :(
Comment #8
Agileware CreditAttribution: Agileware commentedHave you installed new modules that have a higher weight value than what you originally changed your filefield paths weight to?
I have been running with this weighting fix for 3 months with no issue.
Comment #9
alisonI have had this problem and it's driving me crazy!! But I will try the weight fix.
Do y'all think this issue and http://drupal.org/node/844368 are related/the same?
Also, do you think this issue and the issue I linked to (844368) might be related to this other temp paths issue? http://drupal.org/node/650664
(subscribing...)
Comment #10
hefox CreditAttribution: hefox commentedHaving similair issues
In my case, as far as I can telll, the _field_file_cache is never cleared, which isn't a problem.. till something calls node_load during the same page (static cache, only persists for the current page).
So in my case
1) field_file_load is called before filefile_paths, _field_file_cache the result
2) filefield_paths does it work
then if ...
3) Node load is called for that node during the same page load
4) content_load load the files
5) filefield_field_load grabs the cached, incorrect filepath
6) content_load caches the result (it drupal caches, ie cache_set, all field information, so until that is cleared, ie via node save, every node_load returns that cache no matter the page load).
... And thus, BAM.
In my case it was nodelrelationships node add popup that was calling node_load to get the title I suspect.
The weight trick likely worked due to the situation being the other modules calling node_load, then filefiled clears the cache.
Wouldn't work in all cases though, like my case cause the node_load is called in a final submit handler for noderelationship.
But simply clearing the _field_file_cache should address it :).
Comment #11
nplus1 CreditAttribution: nplus1 commentedi have the same issue but with the file name not the path: http://drupal.org/node/844368 you need to save it twice to get the right name in your page. the 3 lines above fixed my problem! thanks!
Comment #12
alisonI just tried the patch at #10 -- brilliant! Totally fixed the problem(s) I was experiencing (see #9)!! Thank you, hefox!!
(Just so y'all know, I applied the patch manually because the site in question is on, erm, "special" hosting that does not include command-line access -- as such, I can not speak to whether or not the patch can be applied without problems etc..)
Comment #13
ShadowMonster CreditAttribution: ShadowMonster commentedsubscribing
Comment #14
jejk CreditAttribution: jejk commentedsubscribing
Comment #15
Magnus CreditAttribution: Magnus commentedThis took the whole evening to figure out. I thought I made some mistake with the Tokens in my paths until I finally found this thread. The patch in #10 works great. Thanks a lot!
Comment #16
Deciphered CreditAttribution: Deciphered commentedCommited to DRUPAL-6--1: http://drupal.org/cvs?commit=434406
Comment #18
joshuajabbour CreditAttribution: joshuajabbour commentedI know this is fixed in dev, but I need a patch usable by drush_make until there's a new stable release.
Comment #19
joshuajabbour CreditAttribution: joshuajabbour commentedone more try. not sure why the second of these seemingly identical patches applies, but...
Comment #20
Todd Zebert CreditAttribution: Todd Zebert commentedUsing 6.x-1.x-dev (2011-Feb-24) and module weight 100, still getting problem. Although I'm uncertain now if Saving first is still required, or just a good idea?
Comment #21
TravisCarden CreditAttribution: TravisCarden commentedI still have this problem using 6.x-1.4. The code supplied in the patches above is absent from the module. Perhaps we had a regression? The patch in #19 solves the problem. (Thanks joshuajabbour.) Can we get it committed again?
Comment #22
jthomasbailey CreditAttribution: jthomasbailey commentedNewest Dev seems to have it.
Comment #23
aitala CreditAttribution: aitala commentedA quick question - if I apply patch to the current release version of FileField and resave every affected node through View Bulk Operations, will that fix the 'file not found' issue?
Thanks,
Eric
Comment #24
kbk CreditAttribution: kbk commented2 years since a stable D6 release. Doing so may head off spurious issues on old topics like this. It would have also spared me the last hour of googling.
Comment #25
roball CreditAttribution: roball commentedThe fix is now officially available in version 6.x-1.5.