Issues with output buffering in CakePHP
Posted by Felix Geisendörfer, on Jul 16, 2006 - in PHP & CakePHP » Core & Hacking
Output buffering is a useful way to accomblish things in php like gzipping all html output and such. A while ago I wrote about it on this blog (see "A miracle called gzip") as well.
The reason I write about it again is, that I have discovered a little issue with it in CakePHP. Because if you use:
or similar commands in your beforeFilter, you might suddenly notice that setting DEBUG > 1 in app/config/core.php will not give you the usal sql dump any longer. I'm not quite sure why this happens, but I think it's because CakePHP uses ob_buffering as well so there might be conflicts. The easiest solution I found is this one (this time as a complete code example):
-
if (DEBUG<2)
-
{
-
$offset = -1;
-
$ExpStr = "Expires: " .
-
}
I had a hard time debugging this issue today, so I hope this might saves you the trouble I had ; ).
--Felix Geisendörfer aka the_undefined