Problem
Described here #2629120: After entity was removed the file should be removed too. After that I've applied all necessary patches.
Also some comments from #2479523: Add a hook_file_stream_wrapper_uri_normalize_alter() hook look related: https://www.drupal.org/node/2479523#comment-10098768 together with https://www.drupal.org/node/2479523#comment-10098928.
Reason (possible?)
While applying the patch for File Entity, I've noticed that neither amazons3_file_entity_upload_destination_uri_alter nor amazons3_file_stream_wrapper_uri_normalize_alter appear in 7.x-1.x while they are in place in 7.x-2.x - but they both look required as otherwise patches listed at project main page are meaningless: they are both implementations of hooks added by the forementioned patches, so it looks suspicious that they are missing.
Solution
Backport amazons3_file_entity_upload_destination_uri_alter & amazons3_file_stream_wrapper_uri_normalize_alter.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 2639230-fe_paths-avoiding_empty_path_config-1.patch | 510 bytes | PatchRanger |
Comments
Comment #2
PatchRanger commentedMarking as major as it leads to needless costs.
Comment #3
PatchRanger commentedIt is better to upgrade to 7.x-2.x: https://www.drupal.org/node/2629120#comment-10690542 .
Comment #4
PatchRanger commentedI've finally debugged it completely. It is integration issue which relates to AmazonS3, File Entity & File Entity Paths. Now it became clear that it's more File Entity Paths issue. Let me explain: AmazonS3 considers a file path as bucket & filename as key, default File Entity Paths configurations leaves file path empty, it leads to file paths like
public:///image.jpg(note triple slash) - they are not valid filenames, unlink silently fails.I've tried changing file path composing, avoiding redundant slash (so paths became like
public://image.jpg) - it didn't help. Looks like AmazonS3 requires not empty file path.Attaching patch, which changes default config, please review. It (together with patch from #2629120: After entity was removed the file should be removed too: https://www.drupal.org/node/2629120#comment-10703864) fixes the issue.
Comment #5
PatchRanger commentedMisnamed the previous patch, correcting.
Comment #6
sgdev commentedHave been using this patch without issue, thanks.
Also related is a patch we created for the S3 File System module which uses this same code: https://www.drupal.org/project/fe_paths/issues/2969080