A messy one regarding private file downloads. I'm admittedly back a few minor versions on core, but I've looked around the source and don't think the problem has been addressed. Thus the post:
I have a content type that contains a standard image file field. As noted, the files are handled through the private file download scheme. The images can be large, so I've set up a hook_file_download() handler to watch for the downloads of these images and set up headers so that the images will be properly cached in the browser. This is all working as intended, except:
When one of these nodes is rendered, it requests two versions of the node's image, via the imagecache system. A small one goes directly onto the page and a larger one goes into a hidden div for possible presentation later, on request. I can see both of these requests hitting in the server logs. SOMETIMES, but not always, I get several messages like so: Notice: Array to string conversion in drupal_send_headers() (line 1243 of /var/www/html/mysite/includes/bootstrap.inc).
This is inside drupal_send_headers(), and a few watchdog statements show that I'm getting an array of values for the variable $value
, making the statement header($header_names[$name_lower] . ': ' . $value)
unhappy. (This is around line 1243, for those of you following along.)
As I said, this only happens sometimes. My admittedly uninformed guess is that, when the timing is just right (wrong? :), the two requests for the same file get intermingled and step on each other in ways that they shouldn't, causing the problem. I've put a bunch of watchdog statements into my hook_file_download handler, and I can see these multiple calls running through the code in an interleaved way.
As a workaround, I'm hoping to find a way to keep one of the requests from autoloading, but, in the meantime, I think there's a problem. Does anybody out there have any insights? Thanks!