Permalink
Browse files

Only ob_end_flush() if the buffer is not empty. Fixes 'headers alread…

…y sent' warnings.
  • Loading branch information...
1 parent bc9259e commit 17bde5d636db47b2cb73316c86199805407aaca2 @leth leth committed Aug 25, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 bootstrap.php
View
@@ -108,7 +108,18 @@
require APPPATH.'bootstrap'.EXT;
// Disable output buffering
-ob_end_flush();
+if (($ob_len = ob_get_length()) !== FALSE)
+{
+ // flush_end on an empty buffer causes headers to be sent. Only flush if needed.
+ if ($ob_len > 0)
+ {
+ ob_end_flush();
+ }
+ else
+ {
+ ob_end_clean();
+ }
+}
// Enable the unittest module
Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest'));

0 comments on commit 17bde5d

Please sign in to comment.