Data loss: Deleting a translation of an entity deletes all file_usage entries for files referenced by the entity

Created on 19 August 2016, over 8 years ago
Updated 19 June 2023, over 1 year ago

Problem/Motivation

All 'file' field usages belonging to an entity are deleted when an entity translation is deleted. The deletion of an entity translation should decrement the file usage only vir file fields of contained by that translation.

Steps to reproduce:

  1. Create a content type with an image field
  2. Enable translation for your content type and image field
  3. Create a new node in English, (including uploading a file to the image field)
  4. Add a translation of the node (Spanish, let's say). You can leave the same image in place, or use a different one, shouldn't matter.
  5. Delete just the Spanish translation of the node.
  6. Observe that the file_usage entry for the referenced file has been completely wiped out, despite the file still being in use by the English version. The status flag in file_managed also gets set to 0 making it eligible for cleanup.

This happens because FileFieldItemList::delete() is not aware of entity translations. Entity translation deletion is piped throughFileFieldItemList::delete() as a normal entity deletion. The bug is revealed by the test-only patch.

Because this bug leads to data loss, is marked as Critical.

Proposed resolution

Fix it.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

8.1 ⚰️

Component
File moduleΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States azinck

Live updates comments and jobs are added and updated live.
  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

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.71.5 2024