5

I wonder which files are being considered to go through hook_file_download. When this function is triggered, what are conditions ?

(Generally, how I can track myself hooks conditions ?)

I am trying to put some custom created download links (files are not uploaded via drupal, but link to them are defined manually, as described in this issue.)

EDIT: For those searching for hook_file_download related issue, it seems that it is triggered (also) whenever you try to access a valid link to a file in private filesystem.

4

The easiest way to track where core hooks are called, from core code, is to look on the docs page.

For hook_file_download(), you'll see this:

enter image description here

A nice list of all implementations/invocations of the hook with links to the relevant functions.

For the cases that don't get covered there, I usually just grep the codebase for, e.g.

module_implements('file_download'

That takes me straight to file.inc, and the file_download() function, which I guess answers your main question.

If that's not quite enough, I thoroughly recommend using Eclipse/Netbeans with XDebug which will let you set breakpoints to see what's happening in more depth.

  • o.O it is triangle toggle icon :) . Somehow I overlooked this for many, many times! Thanks! – NenadP Apr 4 '13 at 10:51
  • 1
    Yeah I remember the Eureka moment when I found those triangles too ;) – Clive Apr 4 '13 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.