Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
When using with CCK FileField, content cache (cache_content table) is still showing the first path - before moving file.
Example:
FileFiled path: subdir
FileField Paths path: subdir/[some-token]
Content cache will show the file under "subdir" path after node update and new file upload.
Lowering the module weight fixes the issue but IMO is still a bug.
Comment | File | Size | Author |
---|---|---|---|
#7 | clear-filefield-cache-on-update-2.patch | 791 bytes | gnindl |
#4 | clear-filefield-cache-on-update.patch | 928 bytes | gnindl |
Comments
Comment #1
askibinski CreditAttribution: askibinski commentedI had this exact same problem when using imagefield + display suite + filefield_path + imagecache.
Imagegache presets shown through display suite (nd_contrib, node display) were broken because the 'filefield path'-part was missing.
The solution was to change the weight of this module from 0 to -1.
But I'm not sure where to file this issue as there are so many modules involved.
Comment #2
claudiu.cristeaFailed also to find the cause. There is a
at one step but I think after this some module rebuild the cache using old location.
Comment #3
antiorario CreditAttribution: antiorario commentedI think this is a very big issue. Yes, lowering the module weight to -1 seems to be working, but the reasons behind it should be investigated. Changing it to "major".
Comment #4
gnindl CreditAttribution: gnindl commentedProblem:
The file is initially uploaded to the base directory, e. g. "files", with its original name. Then the module filefield_paths moves/renames the file according to the configured token, e. g. node id. The filefield_paths module does this in hook_nodeapi($op = 'update'), i. e.
filefield_paths_node_update() and filefield_paths_filefield_paths_process_file(). Unfortunately the filefield module manages in the same hook, i. e. filefield_field_update(), an internal filepath cache (see field_file_save() and _field_file_cache()). The filefield
module caches the old path to the table cache_content BEFORE filefield_paths can do its job.
Solutions:
1) Change the module weight of filefield_paths one below filefield
2) Patch filefield path by clearing the internal cache of the filefield module (see attached patch)
3) Change the filefield cache (function _field_file_cache) behavior. Maybe remove this cache at all or adding the node as an addition argument to hook_file_update, so that implementing modules can properly react on changes. Or add another filefield cache hook. I think removing this cache is the best option, I don't see any major performance improvements.
I will file a bug in the filefield issue queue as well as 3) is the preferred the solution.
Comment #5
gnindl CreditAttribution: gnindl commentedIssue filed for filefield module: #1156308: Problems with internal filefield cache for other file handling modules
Comment #6
quicksketchIf wanting to clear the cache on a file, you should use the public function field_file_load() to reset the file cache on a file, not the private function _field_file_cache().
Comment #7
gnindl CreditAttribution: gnindl commentedPatch from comment 4 has been adapted to use the public function field_file_load() instead of invoking the private function _field_file_cache().
Comment #8
crea CreditAttribution: crea commentedSubs
Comment #9
jaydub CreditAttribution: jaydub commentedRan into this issue as well today and am using the 6.1.4 release. Still needs to get a QA review on our end before I'd say reviewed and tested but so far so good.
Comment #10
kongoji CreditAttribution: kongoji commentedtested patch #7, it worked very well form me
Comment #11
Vuds CreditAttribution: Vuds commentedPatch from #7 appears to not work anymore after the lasts updates in FileField/ImageField to 6.x-3.10. It was working very well before that.
Comment #12
manuel.adanPatch from #7 still works for me on filefield 6.x-3.10 after updating from 6.x-3.9
Comment #13
jrockowitz CreditAttribution: jrockowitz commentedAfter pinpointing this exact issue... and then finding this issue.
Patch #7 resolved the problem for me with fieldfield_paths 6.x-1.4 and filefield 6.x-3.10.
Comment #14
amanire CreditAttribution: amanire commentedPatch #7 also worked for me with fieldfield_paths 6.x-1.4 and filefield 6.x-3.10. Is this committed in 6.x-1.x-dev yet?
Comment #15
jrockowitz CreditAttribution: jrockowitz commentedI think this is a duplicate ticket which was resolved in 6.15 via #635854.
The solution in #635854 was to use the private
_field_file_cache($file, TRUE);
function.