Deleting an entity with revisions and file/image field does not release file usage of non-default revisions, causing files to linger

Created on 4 August 2011, almost 13 years ago
Updated 14 March 2024, 3 months ago

Problem/Motivation

Images/files uploaded to a file/image fields on entities with multiple revisions are never deleted, even when the entity is deleted. Because the file usage counts for the revisions is never released.

Steps to reproduce:

  1. create an article node with an image A uploaded to its image field
  2. verify that the uploaded file A has its status column in the file_managed table set to 1,
    and it has 1 usage in the file_usage table
  3. edit the node, check the "Create new revision" checkbox, remove the original image A and upload a new image B, save
  4. verify that the uploaded file B has its status column in the file_managed table set to 1,
    and it has 1 usage in the file_usage table. Verify that the rows for file A are unchanged in both tables.
  5. delete the article
  6. verify that the uploaded file B has its status column in the file_managed table set to 0, and it has no row anymore in the file_usage table
    • Expected result: file A has its status column in the file_managed table set to 0, and it has no row anymore in the file_usage table
    • Actual result: file A has its status column in the file_managed table still set to 1, and it still has n1 usage in the file_usage table
  7. run cron 6 hours later (this is the default value of the temporary_maximum_age setting in system.file)
  8. verify that uploaded file B is now removed (because usage = 0)
    • expected result: the uploaded file A is still present (because usage > 0)
    • actual result: the uploaded file A is absent (because usage = 0)
  9. Proposed resolution

    TBD, see #126 for an summary of comments #1–#125.

    Remaining tasks

    TBD

    User interface changes

    None.

    API changes

    TBD

    Data model changes

    TBD

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
File moduleΒ  β†’

Last updated 4 days ago

Created by

πŸ‡¬πŸ‡§United Kingdom idiotzoo

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • PostgreSQL

    Particularly affects sites running on the PostgreSQL database.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024