I have File entity module installed and I have images stored as private files. When Drupal attempts to create image style variants of these images then I receive the following error:
Notice: Array to string conversion in drupal_send_headers() (line 1220 of /home/johnny/workspace/quadrupal7/includes/bootstrap.inc).

This is caused because both the file.module and the file_entity.module return the same headers in their hook_file_download. In file.inc in the file_download function an array_merge is used such that the "headers" stay correct. image.module uses a module_invoke_all which uses an array_merge_recursive resulting in that duplicate headers are turned into arrays which causes above error.

Comments

Johnny vd Laar’s picture

I'm in the process of creating a patch for this that adds a helper function that both file_download and image_style_deliver can use.

Johnny vd Laar’s picture

StatusFileSize
new2.61 KB
Johnny vd Laar’s picture

Status: Active » Needs review
rudiedirkx’s picture

Status: Needs review » Needs work

You left

if (in_array(-1, $headers) || empty($headers)) {

in image_style_deliver(). It'll never be -1, because that's now handled by file_download_headers().

irishdan’s picture

I also had the same issue. The patch appears to have worked for me. RTBC?

dan

mindgame’s picture

It also happens when IMCE is installed.
In module_invoke_all(), image_file_download() returns:

Content-Type=image/jpeg
Content-Length=123456
Cache-Control=private

and imce_file_download() returns:

Content-type=image/jpeg
Content-Length=123456

which are incorrectly merged to:

Content-type=image/jpeg
Content-Length=Array
Cache-Control=private

causing the above mentioned PHP notice.

Using array_merge instead of array_merge_recursive would result in:

Content-Type=image/jpeg
Content-Length=123456
Cache-Control=private
Content-type=image/jpeg

All header names being converted to lowercase in drupal_send_headers() anyway.

tobiasb’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#1891228: image_style_deliver can create invalid headers