Jump to content

[SOLVED] Output buffers disappearing in script


citpes

Recommended Posts

Hey guys

 

I'm having a problem with output buffers in php.  I have been coding php for awhile, but not used them until now.

The problem is that my buffers seem to be disappearing halfway through my script.  I have done some debugging and it seems to happen when I reference an array key that doesn't exist.  I have notices turned off in my php.ini.  I'm assuming it has something to do with php trying to suppress the notice warning.  I might be wrong that that is even the cause, but I cant find anything on google about buffers going awol and its my best guess so far  ::)

 

Anyone else had this, or am I just plainly doing something wrong.

 

Thanks in advance.

 

PS: I didnt post code because its not a short script, I can however try to extract the relevant parts if anyone thinks it will help.

Link to comment
Share on other sites

php 5.2.4 has a bug when php terminates due to a fatal runtime error that the output buffer is not flushed as part of the shut down logic.

 

What version of php are you using?

 

What exactly is the error message from your web server log?

 

It would probably be a good idea to correct the logic to prevent referencing array keys that don't exist. Code should not normally triggers any notice/warning/fatal errors.

Link to comment
Share on other sites

I'm using 5.2.1.

 

There isnt an error at all, and all the output shows on the screen in the correct order.  The problem is when it gets to the point of the bad array key, it seems to flush everything and lose the current buffers (like a script termination would, but it continues to run the script).

 

So if you look at the output, you wouldnt even know there's a problem.  I only noticed because now I want to flush some output to a buffer at the top of my script, and show it later.

Link to comment
Share on other sites

I would like to state, for the record, that I'm an idiot :-[

 

There was a custom error handler used, that did nothing but return true (which just returns control to the default error handler.  I think it did this because error handling was going to be put in).  But before returning true, it looped through all open buffers and flushed them.

 

I never even thought to look at the error handler because there was no error being thrown.

 

Sorry for the waste of time, and thanks for taking the time to try help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.