[TYPO3-core] RFC #12498: t3lib_div::flushOutputBuffers can't work

Francois Suter fsu-lists at cobweb.ch
Fri Nov 27 09:14:52 CET 2009


Hi Steffen,

> Bugtracker references:
> http://bugs.typo3.org/view.php?id=12489

Correct reference: http://bugs.typo3.org/view.php?id=12498

> Problem:
> #12189 added two functions: cleanOutputBuffers() and flushOutputBuffers()
> The latter one can't work, as it's not possible to send the header after 
> content has been sent out:
> 
> while (ob_get_level()) {
>   ob_end_flush();
> }
> header('Content-Encoding: None', TRUE);

Actually the header() call was removed, which suppressed the warnings, 
but that doesn't solve the problem you're mentioning. Indeed some 
outputs are broken when compressionLevel is set to a non-zero value. In 
the case you mention, it's phpunit's BE module.

> Solution:
> Use ob_get_clean() to get the buffer's contents, send the header and 
> then print it out.

Funnily enough your patch works even though it seems wrong. Indeed:

$obContent .= ob_get_clean();

this doesn't get the content, because ob_get_clean() returns a boolean 
(at least according to the PHP manual). I'm attaching a new version of 
this patch, which uses ob_get_contents() before calling ob_get_clean(). 
This version works fine for me.

However I'm disturbed by a number of things:

1) I don't understand why the current code doesn't work. ob_end_flush is 
supposed to output the buffer then empty it. This does work in the case 
of the cli_dispatch script, for example. I don't know why it doesn't 
work for phpunit's BE module.
2) for your patch to work, header('Content-Encoding: None', TRUE); has 
to be added again. I'm wondering if this is correct, because the 
encoding might vary. Or does the output of each buffer just "join" the 
output of the main buffer which still has the correct encoding?

Any buffer guru out there who could clear things up?

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 12498-v2.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20091127/ae45d83b/attachment.asc>


More information about the TYPO3-team-core mailing list