Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#2 | 1811238.patch | 1.08 KB | lambic |
Comments
Comment #1
quicksketchFileField 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.
Comment #2
lambic CreditAttribution: lambic commentedI 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.