[D7] Don't trigger hook_file_download when no file is requested

Created on 7 May 2021, over 3 years ago
Updated 17 June 2024, 5 months ago

This is a backport of: https://www.drupal.org/project/drupal/issues/3016814 β†’

-------------------------
Original text:
-------------------------
I have a implementation of hook_file_download because I check if this is a private/specific file and do a redirection for specific link:

function my_file_download($uri) {

 //some code here
 // if(substr($uri,0,26) =='private://specificcontent/'){
    header("location:http://mysite.com/myURL");

}

But, when I remove a file using user interface, this function too is called, generating a error, because the code try redirect for "http://mysite.com/myURL". I believe that when the file is deleted, not is correct receive a call in hook_file_download. But, case if it is not evitable, what I need do for verify that is a delete command and ignore redirection command?

There is a useful solution for version 8, but I haven't found the same solution for version 7 of drupal:

https://www.drupal.org/project/drupal/issues/3016814 β†’

πŸ› Bug report
Status

Fixed

Version

7.0 ⚰️

Component
File systemΒ  β†’

Last updated about 11 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024