diff --git a/src/Whoops/Run.php b/src/Whoops/Run.php index 52486d0d..14bd1bfe 100644 --- a/src/Whoops/Run.php +++ b/src/Whoops/Run.php @@ -393,7 +393,7 @@ public function handleException($exception) // @todo Might be able to clean this up a bit better if ($willQuit) { // Cleanup all other output buffers before sending our output: - while ($this->system->getOutputBufferLevel() > 0) { + while ($this->system->getOutputBufferLevel() > 0 && $this->system->getOutputBufferLength() > 0) { $this->system->endOutputBuffering(); } diff --git a/src/Whoops/Util/SystemFacade.php b/src/Whoops/Util/SystemFacade.php index 9eb0acfa..4d1c35b6 100644 --- a/src/Whoops/Util/SystemFacade.php +++ b/src/Whoops/Util/SystemFacade.php @@ -77,6 +77,14 @@ public function cleanOutputBuffer() return ob_get_clean(); } + /** + * @return int + */ + public function getOutputBufferLength() + { + return ob_get_length(); + } + /** * @return int */