Duplicate managed file entries for images uploaded in bulk

Created on 29 September 2025, 4 days ago

Problem/Motivation

When uploading Image media in bulk, duplicate entries are created in the file_managed table.

Steps to reproduce

  1. Install the latest Drupal core 11.x using the standard profile.
  2. Enable media_bulk_zip_upload and its dependencies (core Media module).
  3. Log in as an administrator.
  4. At /admin/config/media/media-bulk-zip-upload-config, enable ZIP uploads for the Image media type.
  5. At /admin/structure/media/manage/image/form-display, customize the media_bulk_zip_upload form display to show only the needed fields (remove the Image field, for example).
  6. Create a ZIP file that includes two image files.
  7. At /admin/content/media, press Bulk upload Image media.
  8. Upload your ZIP file.
  9. Note the Media page at /admin/content/media now has 2 new entries, one for each image.
  10. Visit the Files page at /admin/content/files.
  11. Note there are 5 new entries: One temporary entry for the ZIP file, and two permanent entries each for the two images.
  12. Note the two entries for one image both reference the same media entity.
  13. Inspect the database table file_managed.
  14. Note there are two entries for each image, which are identical except for the fid and uuid columns.
  15. At /admin/content/media, press Add media and then click Image.
  16. Upload a new image and fill out all required fields.
  17. Save the image.
  18. Note the Media page at /admin/content/media now has one new entry for the new image.
  19. Visit the Files page at /admin/content/files.
  20. Note there is only one new entry for the new image.
  21. Inspect the database table file_managed.
  22. Note there is only one entry for the new image.

The duplicate file_managed entry bug does not happen when uploading individual images, nor when bulk uploading for the Document media type. There may be something under the hood of image file processing - not in this module? - that causes the problem.

Proposed resolution

Prevent creation of duplicate entries in the file_managed table when bulk uploading images.

Remaining tasks

Investigate the source of the issue, which may be in another module or in core.
MR and test.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cboyden

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.

No activities found.

Production build 0.71.5 2024