Duplicate Files in Different Bundles Get Skipped

Created on 13 April 2021, about 3 years ago
Updated 5 June 2023, about 1 year ago

Problem/Motivation

If the same file has been added to two or more nodes in two or more bundles, the newly-created media ID of that file will only be associated with the first instance. Finding the media ID during the second phase of the migration is limited to the step1 map of the bundle associated with that particular node

Steps to reproduce

  1. Add image file (e.g. file01.jpg) to node in any bundle, e.g. article
  2. Add same image file to node in another bundle, e.g. page
  3. Run Migrate File to Media
  4. Observe that while file01.jpg exists in the media "library" it only appears on the first node (e.g. article) and not any others (e.g. page)

Proposed resolution

Alter FileIdLookup method to either examine all step_1 maps, or perhaps more efficiently, query the database to find the media id if not found in the bundle map.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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.

  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine
  • @hitchshock opened merge request.
  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine

    @elimw it looks like a project-specific solution. Also, it doesn't cover the following cases:

    • When we use other media types for migration - e.g. files.
    • When the file wasn't mapped.
    • Translations.

    I provided another solution for that. We have the migrate_file_to_media_mapping mapping table, why not use it?
    - Created event subscriber to add newly created media entities to the mapping table, so we will exactly to know which media matches the current file.
    - For translation use file_id_lookup instead of the migration_lookup. Thus, we also solve this problem for translations.

  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine

    Tested the module after the fixes on the empty and real projects.

    P.S. Keeping a ticket in review status to allow someone else to review it. If the task remains unchanged for 2 weeks, the solution will be automatically added to the dev branch.

  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine HitchShock Ukraine
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024