This appears multiples times after images are uploaded:
Notice: Array to string conversion in drupal_send_headers() (line 1236 of /var/www/docroot/includes/bootstrap.inc).

Drupal versions affected: 7.36 / 7.38

Comments

dxx’s picture

Issue summary: View changes
linucksrox’s picture

I just want to mention that I'm having this exact issue, but I don't use either the Bulkupload or Field Collection modules. Should this issue be reported in Drupal core (I have the issue with 7.36 and 7.37)?

Lycee van Gogh’s picture

Same problem from 7.35 to 7.37 after moving the website to a new server (PHP is now 5.5xx).
I know it is only a administrator problem but it is quite annoying !

pbosmans’s picture

Same issue here after update from php5.4 to php5.5

dqd’s picture

confirmed bug on D 7.38 when using private files directory as default and showing uploaded core system user pictures. So this is not a Field Collection Bulkupload issue but probably a Drupal core issue. I move this issue to D7 core file system. Feel free to change this if I am mistaken.

dqd’s picture

Title: Notice: Array to string conversion in drupal_send_headers » Notice Array to string conversion in drupal_send_headers() line 1236 bootstrap.inc
Project: Field Collection Bulkupload » Drupal core
Version: 7.x-1.0-alpha1 » 7.x-dev
Component: Code » file system
Priority: Normal » Minor
Issue summary: View changes
Issue tags: -PHP warnings (duplicate tag), -headers

... And please don't use issue tags randomly. Before adding tags read the issue tag guidelines. Thanks.

jrb’s picture

Status: Active » Needs review
StatusFileSize
new480 bytes

The notice is generated because the values of three headers (Content-Type, Content-Length, and Cache-Control) are all arrays rather than strings. In modules/image.module, the function image_style_deliver() sets the headers it will use around line 836:

$headers = module_invoke_all('file_download', $image_uri);

If you have both the file and file_entity modules enabled, it will call the hook_file_download() implementation for each. Both of these ultimately do this:

return file_get_content_headers($file);

Which returns an array:

return array(
  'Content-Type' => $type,
  'Content-Length' => $file->filesize,
  'Cache-Control' => 'private',
);

As a result, the $headers variable isn't a simple key-value array-- module_invoke_all() creates an array with the duplicate values for each key. image.module then tries to simply loop through the headers and call drupal_add_http_header() for each one, giving the notice on each array.

foreach ($headers as $name => $value) {
  drupal_add_http_header($name, $value);
}

A simple fix would be to just make sure that each $value is actually a string. If it's an array, we could change it to a string by just taking one of the values (the last?). This could possibly end up discarding some of the headers that are set, but I don't think it's really correct to send multiple values for these headers (which is possible by setting $append = TRUE in the call to drupal_add_http_header()).

I've attached a patch that does this.

Another solution may be to change how the file and file_entity modules work together so they don't both try to set the headers. I'm not sure how possible that would be, though.

marcoscano’s picture

I can confirm the issue is present with Drupal 7.39 + file_entity (7.x-2.0-beta2), when saving private field images attached to the user account.

Patch in #7 eliminates the warnings in my case.

mstrelan’s picture

I think this is a duplicate of #1891228: image_style_deliver can create invalid headers, but have not confirmed

linucksrox’s picture

Unfortunately I don't believe this is a duplicate of #1891228: image_style_deliver can create invalid headers because I'm still seeing this error consistently after having upgraded to 7.42 which includes that patch. I am also seeing the issue after having applied patch #7.

pflork’s picture

I'm still seeing this too with Drupal 7.50. Anybody else found a fix around there ?

staniel25’s picture

A manual entry of #7 worked for me. Using 7.52. JRB, Thanks for all the work, its greatly appreciated.

k8e1050’s picture

drupal 7.52 patched image module on local test site in hope but no difference. Still getting Array to string conversion in drupal_send_headers multiple notices , using only attached pdf file in private upload directory. Upload is fine and viewable . Not sure if I should raise another header issue , but all similar issues seem to be related to image module, but I'm not using that module yet. Any Ideas ?

biigniick’s picture

i'm having the same issue with the file upload of an mp3 file to a file field...

drupal 7.54
media 7.x-2.3
file entity 7.x-2.0

ñull’s picture

Status: Needs review » Reviewed & tested by the community

I had the same issue. After manually applying patch #7 notices no longer appeared. I feel free to mark this reviewed and tested.

fonant’s picture

I'm getting this when generating private derived images.

The header with the array value is Cache-control and the value is [0 => 'private', 1 => 'private'].

Will report back if I have time to locate the cause.

OK, several headers have array values. I can fix the problem more robustly by adding the #7 patch method to bootstrap.inc.

poker10’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

The patch in #7 does not apply anymore. There were changes in image_style_deliver() recently. It needs to be rerolled and verified if the issue is still present.

Also it would be great to find cause of this issue in contrib modules, because Drupal core does not seems to send such headers which can cause this array to string conversion.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.