6.0.0-alpha14
7/2/25

[#7851] "Headers already sent" caused by usage of flush()
Summary "Headers already sent" caused by usage of flush()
Queue DIMP
Queue Version 1.1.1
Type Bug
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester thomas (at) gelf (dot) net
Created 01/15/2009 (6012 days ago)
Due
Updated 08/07/2010 (5443 days ago)
Assigned 01/15/2009 (6012 days ago)
Resolved 08/07/2010 (5443 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
08/07/2010 01:54:41 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
 
08/07/2010 01:54:30 PM CVS Commit Comment #8 Reply to this comment
Changes have been made in CVS for this ticket:

Fix notices with certain output buffer configurations 
(Valentin.Vidic@CARNet.hr, Bug #7851).
http://cvs.horde.org/diff.php/dimp/docs/CHANGES?rt=horde&r1=1.69.2.84&r2=1.69.2.85&ty=u
http://cvs.horde.org/diff.php/dimp/lib/DIMP.php?rt=horde&r1=1.110.2.39&r2=1.110.2.40&ty=u
05/19/2010 01:59:34 PM Valentin (dot) Vidic (at) carnet (dot) hr Comment #7
New Attachment: dimp_flush.diff Download
Reply to this comment
I'm also seeing a lot of 'headers already sent in Unknown on line 0' 
in apache error logs. However the manual for flush says: 
http://php.net/manual/en/function.flush.php

flush() may not be able to override the buffering scheme of your web 
server and it has no effect on any client-side buffering in the 
browser. It also doesn't affect PHP's userspace output buffering 
mechanism. This means you will have to call both ob_flush() and 
flush() to flush the ob output buffers if you are using those.

And if I add an ob_flush() call before flush() the error message goes 
away. Patch is attached.
02/09/2009 02:24:11 PM Jan Schneider State ⇒ No Feedback
 
01/24/2009 04:10:43 PM Chuck Hagenbuch Comment #6 Reply to this comment
Sounds like looking for UTF-8 BOMs at the beginning of your config 
files or the beginning of the translations (?) might be the thing to 
try next here.
01/16/2009 09:24:38 PM thomas (at) gelf (dot) net Comment #5 Reply to this comment
Anyway, it might be this similar issue (w/UTF8 BOM's):
http://trac.roundcube.net/ticket/1483926
Googling I also stumbled over this issue, it lead me to "grep -r flush .",

and helped me to easily "solve" my problem. But I still have no idea

how UTF8 BOM's could cause this issue?! If so, this must be a PHP bug,

is this assumption correct? Shall I search for UTF8-Strings in my config

files??



I still have no clue :-( Thank you for your patience!!
01/16/2009 07:41:42 PM Michael Slusarz Comment #4 Reply to this comment
Cannot modify header information - headers already sent in Unknown
on line 0
This will happen if you have extra space at the top of one of your
config files.
No, I'm pretty sure I haven't - in that case it would tell me file and line
number where the output started. And even without the flush notices
would still be there.
Not necessarily.



Anyway, it might be this similar issue (w/UTF8 BOM's):

http://trac.roundcube.net/ticket/1483926
01/16/2009 09:17:52 AM thomas (at) gelf (dot) net Comment #3 Reply to this comment
Cannot modify header information - headers already sent in Unknown
on line 0
This will happen if you have extra space at the top of one of your
config files.
No, I'm pretty sure I haven't - in that case it would tell me file and line

number where the output started. And even without the flush notices

would still be there.
That is correct - DIMP will catch any unexpected input at the very
end of processing and toss it - but will also this unexpected output
at a DEBUG level to the Horde log.  So this has probably been an
issue forever - you simply haven't seen it because you are not
logging at a DEBUG level.
There is nothing related in my Horde log - but every day (running in

production since four days right now) there have been thousands of

this strange line in my syslog, I'm logging all PHP errors and warnings.



In our beta phase I've had PHP output Notices to the browser, but I

never noticed them, and I still have no idea, WHY they appear. It

could also be related to some strange PHP bug. But fact is: removing

the flush solved it, no more such notice so far.



As soon as time allows me to do so, I'll try to do some more tests.

If someone else running DIMP in a production environment with more

than a few hundred users, preferrably with same / similar PHP version

and APC enabled, could enable logging for PHP errors and tell me

wheter he / she is also seeing this errors, that would be a great help.



For sure it could also be related to our personalisation / customization

work, we strongly modified DIMP's appearance - but (repeating myself)

if I really would have some prior output in my code or config files, PHP

would tell me WHERE output has started.



This one is really strange, I've neve before seen something similar.

Anyone else?




01/15/2009 07:03:12 PM Michael Slusarz Comment #2
State ⇒ Feedback
Reply to this comment
There has been added a flush() call in DIMP.php between revision 1.131
and 1.132 - causing thousands of warning lines a day in my syslog:
Cannot modify header information - headers already sent in Unknown on line 0
This will happen if you have extra space at the top of one of your 
config files.
I'm running latest Debian Lenny, PHP 5.2.6 (untouched, from Lenny) as an
Apache Module, APC Cache enabled.

See http://cvs.horde.org/diff.php/dimp/lib/DIMP.php?r1=1.131&r2=1.132
for the exact change (not documented in CVS log).

Removing the flush()-call solves this issue, no more warnings since then.
That is correct - DIMP will catch any unexpected input at the very end 
of processing and toss it - but will also this unexpected output at a 
DEBUG level to the Horde log.  So this has probably been an issue 
forever - you simply haven't seen it because you are not logging at a 
DEBUG level.
01/15/2009 12:15:56 PM thomas (at) gelf (dot) net Comment #1
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Queue ⇒ DIMP
Summary ⇒ "Headers already sent" caused by usage of flush()
Type ⇒ Bug
Priority ⇒ 2. Medium
Reply to this comment
There has been added a flush() call in DIMP.php between revision 1.131

and 1.132 - causing thousands of warning lines a day in my syslog:
Cannot modify header information - headers already sent in Unknown on line 0
I'm running latest Debian Lenny, PHP 5.2.6 (untouched, from Lenny) as an

Apache Module, APC Cache enabled.



See http://cvs.horde.org/diff.php/dimp/lib/DIMP.php?r1=1.131&r2=1.132

for the exact change (not documented in CVS log).



Removing the flush()-call solves this issue, no more warnings since then.



Kind regards,

Thomas Gelf


Saved Queries