Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The content of the imagefield_crop field is being deleted when saving an entity after upgrading to Drupal 7.29.
This core regression bug was created for the Taxonomy module and seemed related, but does not address contrib modules. :(
To reproduce this bug:
- Create a new piece of content and upload an image to the imagefield_crop field
- Save
- Verify image is saved (it should be visible and stored)
- Edit the same node but don't modify the imagefield_crop field
- Save
- The image has been deleted from the node/profile/entity
The new call to file_download_access($file->uri) (line 515 of file.module as of Drupal 7.29) seems to have triggered this issue.
Comments
Comment #1
citricguy CreditAttribution: citricguy commentedComment #2
citricguy CreditAttribution: citricguy commentedThis issue is resolved by adding a call to hook_file_download().
The below code likely has issues, but it does work for me.
I added it to the bottom imagefield_crop.module
There are a few additional details here if anyone wants to dig in.
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedJust to follow up here, it looks like only the 7.x-2.x branch of the module has this problem (because 7.x-1.x doesn't define its own field)?
I was able to reproduce it using 7.x-2.0, but the core patches from comment #42 onward in #2305017: Regression: Files or images attached to certain core and non-core entities are lost when the entity is edited and saved seem to take care of fixing it, so I think this might get fixed in core.
However, code similar to the above would make sense for this module to add anyway, since otherwise there will be problems on sites that use private files (regardless of Drupal 7.29 or not); for example, problems with end users not being able to view images associated with Image Cropped fields on those sites even when they are supposed to.