When page caching and the Statistics module is enabled, an error is generated at the end of each cached request.

Warning: Cannot modify header information - headers already sent by (output started at /home/chsc/www/drupal7/includes/bootstrap.inc:1155) in drupal_send_headers() (line 1007 of /home/chsc/www/drupal7/includes/bootstrap.inc).

#0  header(Content-Type: text/html; charset=utf-8) called at [/home/chsc/www/drupal7/includes/bootstrap.inc:1007]
#1  drupal_send_headers(Array ([Expires] => Sun, 19 Nov 1978 05:00:00 GMT,[Last-Modified] => Wed, 24 Mar 2010 19:58:42 +0000,[Cache-Control] => no-cache, must-revalidate, post-check=0, pre-check=0,[ETag] => "1269460722")) called at [/home/chsc/www/drupal7/includes/bootstrap.inc:1052]
#2  drupal_page_header() called at [/home/chsc/www/drupal7/includes/bootstrap.inc:1964]
#3  _drupal_bootstrap_page_header() called at [/home/chsc/www/drupal7/includes/bootstrap.inc:1797]
#4  drupal_bootstrap(7) called at [/home/chsc/www/drupal7/modules/statistics/statistics.module:54]
#5  statistics_exit()
#6  call_user_func_array(statistics_exit, Array ()) called at [/home/chsc/www/drupal7/includes/module.inc:686]
#7  module_invoke(statistics, exit) called at [/home/chsc/www/drupal7/includes/bootstrap.inc:868]
#8  bootstrap_invoke_all(exit) called at [/home/chsc/www/drupal7/includes/bootstrap.inc:1905]
#9  _drupal_bootstrap_page_cache() called at [/home/chsc/www/drupal7/includes/bootstrap.inc:1780]
#10 drupal_bootstrap(7) called at [/home/chsc/www/drupal7/index.php:21]

The problem occurs because the bootstrap process ends early with DRUPAL_BOOTSTRAP_PAGE_CACHE, but hook_exit in Statistics module requests a full boostrap after the output has been sent. The full bootstrap includes sending HTTP headers in DRUPAL_BOOTSTRAP_PAGE_HEADERS, but these have already been sent during DRUPAL_BOOTSTRAP_PAGE_CACHE.

Comments

JacobSingh’s picture

Yep, I see this. It sucks too if you're using the syslog module because syslog tries to use theme() which isn't defined and poops its pants with a fatal error.

jergason’s picture

I have been unable to reproduce this bug. I installed Drupal 7, enabled the statistics module, and went to admin/config/system/statistics to turn on the access log and view counting. I then went to admin/config/development/performance and clicked the "Cache pages for anonymous users checkbox and hit save. I created several pages and articles, logged out, and visited them several times each.
I didn't see any white screen of death. I logged back in and checked the drupal logs as well as the apache and php error, and everything appeared to work fine. Can you still get this problem to happen?

Berdir’s picture

Status: Active » Fixed

I'm not seeing this either.

There were some changes recently related to statistics.module and page caching, so I'm guessing that has been fixed too. See http://api.drupal.org/api/function/statistics_exit/7, which doesn't do a full bootstrap anymore.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

fietserwin’s picture

Status: Closed (fixed) » Active

I recently looked at the error log of a live site I already had handed over to a client and saw the log was full with this message. So the issue is still there, also in 7.0. Caching is enabled on their live site but I am not sure about the statistics module. I would like to dive into this and do some debugging but have other priorities for the near future. So I start with just re-opening this one.

Tor Arne Thune’s picture

I also see this with Varnish enabled, but the statistics module is not enabled. I'm not sure where to begin to try to solve this.

fietserwin’s picture

Status: Active » Fixed

I recently updated the site I was experiencing this from D7.0 to D7.9. Since then no single new message (with this warning) was logged anymore. Not with statistics enabled and not with statistics disabled. So I assume it to be fixed by now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

javier.drupal.2012’s picture

Status: Closed (fixed) » Active

Hi,

same issue here. I have activated the Cache pages for anonymous users and I'm getting next error:

Warning: Cannot modify header information - headers already sent by (output started at /home/antri2rm/public_html/includes/bootstrap.inc:1364) in drupal_send_headers() (line 1216 of /home/antri2rm/public_html/includes/bootstrap.inc).

My drupal core version is 7.20
I'm in a shared host then I'm not using varnish or something similar.
I have statistic core module enabled, but it is disabled on its configuration: nor enabled "Enable access log" neither "Count content views"

Any idea to solve this issue?

Thanks
Javier

jukka792’s picture

Version: 7.x-dev » 7.23

I have same problem with version 7.23

Warning: Cannot modify header information - headers already sent by (output started at /home2/mysite/public_html/includes/bootstrap.inc:1368) in drupal_send_headers() (line 1220 of /home2/mysite/public_html/includes/bootstrap.inc).

Statistics module is on + many other modules.
Theme is not touched (responsive bartik)

In the log, "location" field shows that it is "comment/19" which does not exist, never created one. (many other rows with same error in the log)
(Site is transferred from other domain to other, but everything seems to work still.)

Version: 7.23 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.