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.
When trying to do a file_unmanaged_copy() between two URIs to files stored on S3, I got this error from PHP:
The specified file storage-field-image://images/article/2013/02/27/lotus.jpg was not copied because it would overwrite itself.
The error comes from file_unmanaged_copy() which expects the realpath of source and destination to be different OR realpath of source to be FALSE.
Since no code is implemented in the method, it returns NULL for both source and destination, so file_unmanaged_copy() thinks the paths are equal.
Comment | File | Size | Author |
---|---|---|---|
#6 | storage_api-realpath_wrong_implementation-1929100-5.patch | 867 bytes | dansanjou |
#1 | storage_api-realpath_wrong_implementation-1929100-1.patch | 511 bytes | esbenvb |
Comments
Comment #1
esbenvb CreditAttribution: esbenvb commentedThis patch solves the problem.
IMPORTANT: When porting the patch, make sure to provide proper author information as specified on http://drupal.org/user/989064 - thanks.
Comment #2
Island Usurper CreditAttribution: Island Usurper commentedI like it. It'd be kind of nice if it would detect if it's using the Filesystem service and return a good value then, but it's probably not necessary.
Comment #3
jbrown CreditAttribution: jbrown commentedDrupalStorageStreamWrapper is just a hack so that file and image fields can utilise Storage API. It is not intended to be used in this manner.
Comment #4
esbenvb CreditAttribution: esbenvb commented#4 But it's not unusual that a module tries to copy from one file URI to another - and without this patch, it will fail because NULL == NULL and NULL !==FALSE...
Comment #5
bgilhome CreditAttribution: bgilhome commentedIs this on the right track?
Comment #6
dansanjou CreditAttribution: dansanjou commented#5 works for me, I just did a little change to the return value it wasn't returning the correct path with the $storage->getUri
Comment #6.0
dansanjou CreditAttribution: dansanjou commentedtypo
Comment #7
queenvictoria CreditAttribution: queenvictoria commentedWorks for me and fixes an issue with Storage API and PDF to Image
https://www.drupal.org/project/pdf_to_imagefield
Thanks @dansanjou
RTBC +1
Comment #8
Perignon CreditAttribution: Perignon commentedComment #9
Perignon CreditAttribution: Perignon commentedHave to re-roll this patch because of file changes.
Comment #11
Perignon CreditAttribution: Perignon commentedIn dev! Thanks for the review!
Comment #12
Perignon CreditAttribution: Perignon commentedTagging for release documentation.