Training duplicate feature results in duplicate file_managed entries for the same file

Created on 1 December 2022, almost 2 years ago
Updated 21 June 2023, over 1 year ago

Problem/Motivation

Critical because this leads to data integrity issues. The symptom is that you're unable to download files from TFT on duplicated groups. But it could have other implications such as if one of the file entities was deleted.

Steps to reproduce

1. Create a learning path with at least one TFT file. Training A.

2. Duplicate Training A to Training B.

3. Duplicate Training A to Training C.

OpignoGroupManager::duplicateTraining() has logic to try to create a unique filename, but it does this by using the file ID as a prefix.

If you duplicate the same file twice, you get a third file entity, pointing to the same file on disk - this is invalid as far as Drupal is concerned.

It would be possible to fix this by making the anti-duplication logic more robust, and using https://api.drupal.org/api/drupal/core%21modules%21file%21src%21FileRepo... instead of raw copy().

However, there is no reason to make exact duplicates of the same file, instead different media items can point to the same fid. So uploading patch for that.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
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