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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

askibinski’s picture

I 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.

claudiu.cristea’s picture

Failed also to find the cause. There is a

      cache_clear_all('content:'. $node->nid . ':' . $node->vid, content_cache_tablename());

at one step but I think after this some module rebuild the cache using old location.

antiorario’s picture

Priority: Normal » Major

I 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".

gnindl’s picture

Status: Active » Needs review
FileSize
928 bytes

Problem:

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.

gnindl’s picture

quicksketch’s picture

If 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().

gnindl’s picture

Patch from comment 4 has been adapted to use the public function field_file_load() instead of invoking the private function _field_file_cache().

crea’s picture

Subs

jaydub’s picture

Ran 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.

kongoji’s picture

tested patch #7, it worked very well form me

Vuds’s picture

Patch 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.

manuel.adan’s picture

Patch from #7 still works for me on filefield 6.x-3.10 after updating from 6.x-3.9

jrockowitz’s picture

After 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.

amanire’s picture

Patch #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?

jrockowitz’s picture

Status: Needs review » Closed (duplicate)

I 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.