For some reason this started happening a month ago and I can't figure out why. When I create a new node revision and change an image, it used to keep the old file with the revision record. This made it easier to revert. Now when I add a new revision, it deletes the image and the record from the previous revision. Is there any way to stop this?

CommentFileSizeAuthor
#2 1811238.patch1.08 KBlambic
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

FileField shouldn't be doing this. Every new revision should be getting its own file usage records and previous revisions should keep their own files. There was a recent bug fix at #1210710: File deletion not handling deletion of previous revisions correctly, but that had the problem that files *weren't* being deleted, rather than being deleted unnecessarily.

lambic’s picture

FileSize
1.08 KB

I think this problem might be a result of the fix in #1210710. I'm seeing something similiar when hook_file_delete() triggers.

At the end of filefield_delete_file_references() there is a call to node_save(), however in the case of modifying an old revision that's probably not what we want, as node_save() will make that revision the current revision. Instead we want to re-save just that revision without touching the current published version. It looks like _node_save_revision() does that.

Attached is a (currently untested) patch for this. The unfortunate thing about this patch is it requires a second node_load to compare the current vid with the vid we're modifying which obviously has performance implications but I can't come up with a better way without resorting to sql queries.