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.
Problem/Motivation
The docs for hook_file_download()
read:
If the user does not have permission to access the file, return -1. If the user has permission, return an array with the appropriate headers. If the file is not controlled by the current module, the return value should be NULL.
Returning magical intergers is not very self-documenting. There does not appear to be an existing constant we can use in the file module itself.
Proposed resolution
We could do some of the following:
- Add a constant (possibly to FileDownloadController?) Might be named something like
FILE_DOWNLOAD_DENY
or (if on the download controller)DENY
. - Discuss whether the
NULL
"ignore" return value also merits its own constant. - Refactor to use some generic access result mechanism. There might be limitations on what we can do in a minor, even with an upgrade path, but it is worth looking into.
Remaining tasks
TBD
User interface changes
N/A
API changes
TBD
Data model changes
TBD
Comments
Comment #2
xjm