I had been seeing a lot - and I mean a lot - of watchdog notices on one of my sites as follows:
Warning: Cannot modify header information - headers already sent by (output started at [PATH]/includes/common.inc:2700) in drupal_send_headers() (line 1221 of [PATH]/includes/bootstrap.inc).
I tracked down one of the causes to comment_goodness. This module implements a hook_menu_alter() to put comment_goodness_permalink() in place of the comment handler. This is totally cool, save for how it handles comments-not-found situations.
In that case it calls: drupal_not_found() - which calls a page display and kicks off headers and all that goodness. The problem is - so does the menu handler! So now we have two page displays going out, both trying to set headers and boom - watchdog log message pops up because of the second set of headers going out after data has already been sent by the first call.
The fix is really really simple though!
Per direction at https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_... - instead of calling drupal_not_found(), simply return MENU_NOT_FOUND in the menu handler function.
Comment | File | Size | Author |
---|---|---|---|
#1 | comment_goodness-2218501.patch | 428 bytes | Bastlynn |
Comments
Comment #1
Bastlynn CreditAttribution: Bastlynn commentedPatch attached
Comment #2
Bastlynn CreditAttribution: Bastlynn commentedComment #3
formatC'vt CreditAttribution: formatC'vt commentedyes, this patch fix this bug
Comment #5
jessebeach CreditAttribution: jessebeach commentedThanks Bastlynn and formatC'vt!
d12cb7d..a2dcb18
Comment #7
wfragakis CreditAttribution: wfragakis as a volunteer commentedOld bug but took me forever to find this after much searching - this patch solved my watchdog notice:
Warning: Cannot modify header information - headers already sent by (output started at[PATH]/includes/common.inc:2791) in drupal_send_headers() (line 1503 of [PATH]/includes/bootstrap.inc).