I've been using drupal for a while in various configurations and have never had a problem I couldn't figure out with a little research.... Until now :-(

I've been using a new Drupal installation running 4.5.1 in the following configuration (my standard):

3rd Party Modules:

  • Images
  • Quickpost
  • HTMLarea

Software:

  • Lighttpd v 1.3.5 - Chroot
  • PHP 4.3.9 Hardened (run as an FCGI server)
  • MySQL 4.0.22
  • Gentoo Linux Hardened 2.6.x

Everything has been working fine with building the site, and suddenly after adding user #2, it stopped working . (Error message below) I have not edited the source files at yet, and confirmed that there is no white space after the php closing tag on any of the files, which is usually the problem with "Cannot modify header information".

I'm stumped... Any ideas?

The Error Messages:

Notice: Undefined index: messages in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 507

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 258

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 259

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 267

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 275
(Lots of binary junk here)

Comments

neomike’s picture

So, I get get the site viewable with a quick sql command:
delete from cache;

But then I am left with the following error messages:

Notice: Undefined index: messages in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 507

warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/common.inc on line 98.

Once I log in, the messages go away, but once I log out, I go back to the original problem where the site doesnt even display:

Notice: Undefined index: messages in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 507

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 258

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 259

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 267

Warning: Cannot modify header information - headers already sent by (output started at /lighttpd/websites/neocrime.com/includes/bootstrap.inc:507) in /lighttpd/websites/neocrime.com/includes/bootstrap.inc on line 275
(lots of binary junk here)

Any ideas here would be great!

Thanks.

sunnybaba’s picture

Detailed explanation here (with solutions and workarounds)
http://www.siteinaweek.com/howto/headerproblems/headerproblems.html

neomike’s picture

Well. I'm making no progress.

I have another virtual site running off the same directory, and its not having problems. I can only assume the problem is in the data base somewhere.

Thanks for your help in this matter.

HenkPoley’s picture

Tried a simple 'database repair'? Sometime the index tables get broken and the database need to be rebuilt. myphpadmin makes this very simple to do, but searching a bit on the web will bring up how to do in SQL.

neomike’s picture

I tried the database repair to no avail... BUT

I turned off cache support and suddenly everything started working perfectly again.

So, I went to another site I was running off the same directory, and it had cache support disabled. I enabled it, and boom.... same errors. Once cache support was turned off again, everything went back to normal.

So aparently there is a bug in cache support, atleast related to my configuration (since nobody else complained and nobody else seems to use lighttpd).

I doubt anyone is interested, but I'll try to track down the problem and post a bug fix.

gw7’s picture

I have a similar problem with taxonomy_context and cache support enabled. I am using Drupal 4.5.1 on:

Apache 1.3.27
PHP 4.3.3
MySQL 4.0.15
XP Pro

Receiving the following errors:

Notice: Undefined index: messages in 
\www\drupal\includes\bootstrap.inc on line 507

Notice: Undefined index: q in 
\www\drupal\includes\bootstrap.inc on line 413

Fatal error: Call to undefined function: drupal_set_html_head() in \www\drupal\modules\taxonomy_context\taxonomy_context.module on line 17

After enabling cache support I started receiving the errors. Disabling cache eliminates the errors. I really need to use taxonomy_context and have cache support enabled. So, if you do track down the problem please post the bug fix.

Thank You

tropology’s picture

where do you disable cache support?

andrew404’s picture

Hey..... finally someone with a similar problem!!!!
I'm getting the following modify header warnings:
warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\drupal451\includes\common.inc:1) in c:\wamp\www\drupal451\includes\common.inc on line 98.

warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\drupal451\includes\common.inc:1) in c:\wamp\www\drupal451\includes\common.inc on line 155.

This one is when I login and logout. Now that you said it, I think it can be narrowed down to work I did on the site included adding some new users and roles(as well as aggregator stuff

Some others have said something about having spurious characters in one of the files, would you have any idea which (other than common.inc and bootstrap.inc, pretty sure they're okay) ones?

eka’s picture

I'm new to drupal i like the way its done i'm comming from trying mambo

i was getting same error so i disabled cache support and done

no more error messages

i hope it works for ya

Eka

Steven’s picture

You guys were all looking at the wrong issue. As the FAQ in the handbook explains, if "headers already sent" after another error message, then it is most likely /caused/ by the previous error message.

Focus on fixing the errors from top to bottom, and the "headers already sent" messages will most likely disappear.

In this case, the problem was that your PHP configuration was set to output all messages, including notices which are not problems on their own. The fact that a message was being printed to the screen started output prematurely, and prevented sessions and cookies from working.

--
If you have a problem, please search before posting a question.

eka’s picture

Thanks to steven i went and edited my php and changed to this

; - Show all errors, except for notices
;
error_reporting = E_ALL & ~E_NOTICE;

the enabled the cache and no more error or "Notice" messages

Steven: tnx again

Eka

mantis8’s picture

Hi, I'm totally new to Drupal/php, so please bear with me. I just made my first xhtml/css site and then installed Drupal (version 4.5.1). To make a long story short, I got the same header line 155 error as stated above. Which php file do I edit and where/how? Any assistance is appreciated. I have already checked for extra spaces in several different files.

jmoore’s picture

The file you want is php.ini
If you're on a Mac it will probably be in /usr/local/php5/lib
Open it up with a plain text editor and edit the following line:
error_reporting = E_ALL
to:
error_reporting = E_ALL & ~E_NOTICE
Hope that works(I'm having the same problem and haven't tried that fix yet).
Best,
Joe

mantis8’s picture

Thx for the quick reply. I'm using Linux mandrake 10.1 official(http://www.mandrakesoft.com/products/101) and made my xhtml/css pages with Quanta plus 3.2 (http://quanta.sourceforge.net/). I'm under a lot of pressure to get my website up and running fast and needed to make a lot of changes anyways, so in my haste, I had uninstalled/reinstalled drupal 4.5.1. last night and tweaked the bluemarine theme css a bit. Before I went to bed, it was functional and working fine. Overnight, poof!, my site went out the window. It's at: www.fundraising4npos.com, hosted by www.micfo.com. However, I am still getting a similar error (Warning: Cannot modify header information - headers already sent by (output started at /home/mantis8/public_html/includes/module.inc:89) in /home/mantis8/public_html/includes/bootstrap.inc on line 258) and now (Warning: array_key_exists(): The second argument should be either an array or an object in /home/mantis8/public_html/includes/module.inc on line 89). Any how, I never installed drupal or mysql on my hard drive. I only went online to do all the work, so I went through all my server's folders, but didn't find any php.ini file. This is the code for module.inc. Line 89 has "array_key_exists" in it.

* Set the filename of a module, for future loading through module_load()
*
* @param $module
* Name of the module which to specify the filename of.
* @param $pa
* Filename of the module named $module.
* @return
* Filename of module, if no $path has been specified.
*/
function module_set_filename($module, $path = null) {
static $list;

if ($path) {
$list[$module] = $path;
}
else {
return array_key_exists($module, $list) ? $list[$module] : "modules/$module.module";
}
}

I went all through the server and couldn't find any error_reporting code.
Any additional info would be great.

mantis8’s picture

To anybody that may benefit:

I found out from my hosting company that I don't have access to the php.ini file because I have a shared server. Access to the php.ini file requires an expensive dedicated server instead. Then I got some help from my hosting company who said I can modify the .htaccess file instead with the following lines:

php_value error_reporting E_ALL=2038
php_value error_reporting ~E_NOTICE=2038

I don't know much about php, but this fixed my problem and now I can go back to editing my website and set it up the way I want.

ergophobe’s picture

Turning down error reporting is a hack, not a fix.

It's so frustrating that PHP defaults to "split the difference" in the way it does, leading to problems like this. I wish they would just start distributing it set to E_ALL and let sys admins turn the error reporting down/off for live sites/servers as necessary.

Quality PHP code should run fine with error reporting set to E_ALL. Developers should always work with Notices and Warnings being displayed and should not release code that throws Notices or Warnings.

Live sites should have ALL error reporting turned off (display_errors = 0). Errors can still be logged, but should never be sent to output on a live site.

Oh, yeah, I'm here because I'm having the same problems with undefined indexes in the bootstrap.inc file since installing taxonomy_context.

ergophobe’s picture

Better than turning down error reporting, you can check your data. This is a manually generated diff of bootstrap.inc.

<< - means delete that
>> - means insert that

line 85
<<   if (!$files[$type]) {
>>   if (empty($files[$type])) {


line 92
<<   elseif ($files[$type][$name]) {
>>   elseif (!empty($files[$type][$name])) {

line 335
>>  if (!empty($files[$type][$name])) {
<<  if ($files[$type][$name]) {

This leaves open the question of why with turning the cache on creates a problem that doesn't otherwise exist, but I'm too new to Drupal to tackle that one.

coloma’s picture

Thank you! I was having the same problem -- whenever I logged out, the new URL would be "?q="

I'm new (brand new!) to Drupal but do a lot of PHP development so I hate the idea of turning off warnings on my development machine. I patched bootstrap.inc as you suggest and the errors went away.

Another similar error showed up soon after; I fixed it by changing bootstrap.inc line 624 from

  return $_SESSION['messages'];

to

  if ( !empty($_SESSION['messages']) ) {
    return $_SESSION['messages'];
  } else {
    return '';
  }

There might be a more elegant way but this was quick and it works.

Donna

ergophobe’s picture

I'm new (brand new!) to Drupal but do a lot of PHP development so I hate the idea of turning off warnings on my development machine.

Same here. I suppose if we knew our way around, the better solution would be to make sure that variables have the expected defaults.

Barring that, catching and trapping is the next best thing.

Remember, GREP is your friend!