Problem/Motivation
For private files, file download system doesn't consider the published translation.
Steps to reproduce
This issue occurs when content is translatable. File upload field added on the content type is also translatable along with file upload file.
When the translation is published and if we try to access the file attached on translation, it fails.
- Create article content type.
- Add file upload field ensure that upload destination is set to private files
- Enable content translation, content moderation and add language.
- Enable article content type to use content moderation.
- Visit "admin/config/regional/content-language" and enable translation for all the article field including newly added private file field.
Ensure that file upload is also translated, not just alt text and name
- Create the English content for the node (don't upload file yet) and keep it in draft.
- Translate the above english content into other language, upload the private file and publish the translation.
- Check the file path on content translation i.e. /system/files/2025-06/abc.txt.
- Try to access the file using file path directly and see it doesn't work despite the translation is published.
- Publish the "English" translation
- Access the file using direct path like " /system/files/2025-06/abc.txt." and it works because English translation is published.
Proposed resolution
In file_get_file_references()
we should ensure that we check the appropriate translation.
Remaining tasks
- MR
- Add tests
User interface changes
N/A
Introduced terminology
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
Original report by @simbaw
In my site, we enabled workflow and translation.
Reproduce steps:
1. Create a new content A and save to 'Draft'.
2. Translate content A and upload image to image filed, then save this translation to 'Published'.
3. View image by image link:
Actual: Anonymous User can not access this image.
Expect: Anonymous User can access this image.
Root cause: function file_get_file_references() returns is not correct.