Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Experiencing this behavior both with standard Image fields and also with File Entity/Media "fields".
Upon feature activation and the node import process, for nodes containing these types of fields, each file is being duplicated multiple times. Furthermore, with File Entities, there are orphaned records being created in the db.
Interestingly, the number of dupes was only two per file with the Image field, but 4 per file with the File Entity field. :-/ Related to the number of module dependencies the feature module itself has??
Comment | File | Size | Author |
---|---|---|---|
#10 | 1611928-fix-alt.patch | 4.07 KB | tim-e |
#10 | interdiff.txt | 659 bytes | tim-e |
#3 | 1611928.patch | 4.18 KB | xtfer |
Comments
Comment #1
laken CreditAttribution: laken commentedI am also seeing this on 7.x-1.0-alpha6+3-dev. Import of a node with a file field is creating 6 copies of the file! Interestingly, they are not all the same size:
The larger size files looks like the raw Base-64 encoded, the smaller is the actual PDF correctly decoded.
What is causing this?
Comment #2
himerus CreditAttribution: himerus commentedI've been experiencing this too on a new install (custom distribution) after attempting to import the content.
I'm getting upwards of 8 copies of each image. :( not good! Will see soon if I can dig to the bottom of why this is happening.
Comment #3
xtfer CreditAttribution: xtfer commentedThe file import handling seemed to be a little "experimental", so I have rewritten it. =)
This patch updates file handling so that files are created correctly and reused when they already exist (i.e. no duplicates).
It has been tested on a project containing several hundred file references to about 20 image and text files across 8 features, and seems to be working correctly.
Rolled against 2.x, as thats the version we are using, and it affects that module as well.
Comment #4
himerus CreditAttribution: himerus commented+1 for the patch in #3.
This fixes the issue in my install, including in a forked version of defaultcontent.
Comment #5
populist CreditAttribution: populist commentedI tested the patch in #3 and it solves the initial problem of not duplicating images (my fresh install only generates one image file per image), but it will still duplicate files when the file already exists in the file system.
On quick glance, I think all we need to do to resolve this is to do a check to see if the file exists on the file system during the foreach loop this patch provides.
Comment #6
himerus CreditAttribution: himerus commentedI did notice that it still did duplicate files after further testing on multiple installs, some wiping the file system, some not.
Comment #7
sylus CreditAttribution: sylus commentedHas there been any progress on this? Can confirm this problem still exists.
Comment #8
Jeffrey C. CreditAttribution: Jeffrey C. commentedAfter there's a clean patch that solves the issue, I'll commit it.
Comment #9
Jeffrey C. CreditAttribution: Jeffrey C. commentedMeanwhile, please take a minute to check out #1869366: Future Plan.
Comment #10
tim-e CreditAttribution: tim-e commentedFound an issue with the patch in #3. It doesnt seem to add in the alt and title values.
Attached patch and interdiff.
Comment #11
Jeffrey C. CreditAttribution: Jeffrey C. commentedAll right. Anyone can test the patch?
Comment #12
xtfer CreditAttribution: xtfer commentedComment #12.0
xtfer CreditAttribution: xtfer commentedderp
Comment #13
govind.maloo CreditAttribution: govind.maloo at Salsa Digital commentedPatch is working fine
Also used in https://github.com/govCMS/govCMS
moving to RTBC