Problem/Motivation
Administrator cannot access to temporary files without usage that are owned by other users
Steps to reproduce
1. Create a image field in content type.
2. Create a node and upload a image but not save the node.
3. Access to /admin/content/files and the image file is temporary and file usage is 0
4. Click the file link, got Access Deny.
Proposed resolution
Add role check logic in file_file_download function.
If user is the Administrator, allowed to access the file.Instead of just only checking whether the file owner is the same as the current user.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3389028-administrator-cannot-access-file-issue.patch | 1.37 KB | connbi |
Issue fork drupal-3389028
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
connbi commentedComment #3
cilefen commentedComment #4
smustgrave commentedThank you for reporting
Believe next steps would be to add a test case to show the issue and that the patch addresses it.
Comment #7
caesius commentedI have a custom module that generates PDF with a
temporarystatus (deliberate, since they're supposed to be ephemeral downloads) and only user 1 was able to access them. Using this patch allows other admin users to view the generated PDFs.Comment #9
samitk commentedThis patch does not apply to Drupal
11.xor the currentmainbranch, asfile_file_download()has been removed from core.In Drupal 11+ and Drupal 12, file download access is handled via entity access control in
core/modules/file/src/FileAccessControlHandler.php, rather than procedural file download functions.The access logic would need to be implemented as part of the file entity’s download access check.
Adding this for discussion and feedback from others on the preferred approach.