- Issue created by @ninobrownh20
- Status changed to Needs work
4 months ago 9:33am 13 January 2025 - 🇳🇱Netherlands Martijn de Wit 🇳🇱 The Netherlands
There is a patch available. Changing status.
Would be nice if patch goes into a merge request, so it is visible if patch still applies.
Changing status to "Needs work".
- 🇳🇱Netherlands Martijn de Wit 🇳🇱 The Netherlands
also the use case could be a duplicate off: ✨ Prevent duplicates Active
- First commit to issue fork.
- Merge request !21Issue #3423083: Allow to bulk overwrite or replace existing media. → (Open) created by the_g_bomb
- 🇬🇧United Kingdom the_g_bomb
I have created a PR based on the patch supplied in #6 with some coding standards improvements.
This could be considered a duplicate although that doesn't have a solution as yet. The original request is slightly different however, that is asking for a skip if exists feature, this is a replace if exists feature request, both have merit and should exist in and of themselves, I think, so one solution may fix both and it may be that we end up with a selection on the upload form requesting how to handle duplicates.
There still needs to be some investigation into whether https://www.drupal.org/project/media_duplicates → works combined, this issue can be closed, I think.
- 🇬🇧United Kingdom the_g_bomb
One thing I did spot when doing the patch to MR conversion
$duplicates = []; // Loop through each of the uploaded files foreach ($fileNames as $fileName) { $pattern = $realpath . '/*/' . $fileName; $matches = glob($pattern); if (count($matches) > 0) { // If there is already a file in the public directory with the same name $duplicates[] = $fileName; } } if (!empty($duplicateUris)) { // Load the file entities by their URIs. $existingFileIds = \Drupal::entityQuery('file') ->accessCheck(TRUE) ->condition('uri', $duplicateUris, 'IN') ->execute();
The array of duplicates is never used once populated, and I wonder if the $duplicateUris variable is a typo as it is never populated that I can see.
Perhaps the $duplicates is meant to be used in place of $duplicateUris
- 🇬🇧United Kingdom the_g_bomb
FYI: I have installed the media_duplicates module and
a) It doesn't seem to work with media_bulk_upload as you are still able to upload media while duplicates exist
b) When using the media upload only, the new module throws a form error which stops you creating a new media item while the same file exists, it doesn't then update the existing media item instead. - 🇬🇧United Kingdom the_g_bomb
No point reviewing, the duplicates thing is a problem and stops this working