diff --git a/src/php_error.php b/src/php_error.php index fa55cd5..9680678 100644 --- a/src/php_error.php +++ b/src/php_error.php @@ -1135,6 +1135,8 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) { private $classNotFoundException; + private $clearAllBuffers; + /** * = Options = * @@ -1229,6 +1231,8 @@ public function __construct( $options=null ) { $this->applicationRoot = ErrorHandler::optionsPop( $options, 'application_root' , $_SERVER['DOCUMENT_ROOT'] ); $this->serverName = ErrorHandler::optionsPop( $options, 'error_reporting_off', $_SERVER['SERVER_NAME'] ); + $this->clearAllBuffers = ErrorHandler::optionsPop( $options, 'clear_all_buffers', false); + /* * Relative paths might be given for document root, * so we make it explicit. @@ -1466,6 +1470,9 @@ private function startBuffer() { * do want it. However otherwise, it will be lost. */ private function discardBuffer() { + if ( $this->clearAllBuffers ) { + while( @ob_end_clean() ); + } $str = $this->bufferOutputStr; $this->bufferOutputStr = ''; @@ -2620,7 +2627,6 @@ private function runEnableErrors() { // all errors \o/ ! error_reporting( $this->defaultErrorReportingOn ); - @ini_set( 'html_errors', false ); if ( ErrorHandler::isIIS() ) { @ini_set( 'log_errors', false ); @@ -2640,6 +2646,11 @@ function( $code, $message, $file, $line, $context ) use ( $self, &$catchSurpress * silently ignored. */ if ( $self->isOn() ) { + /* + * Turning off 'html_errors' at this point avoids interference + * with xDebugs 'var_dump()'-overload, thus preserving prettyfied dumps + */ + @ini_set( 'html_errors', false ); /* * When using an @, the error reporting drops to 0. */ @@ -2657,6 +2668,11 @@ function( $code, $message, $file, $line, $context ) use ( $self, &$catchSurpress set_exception_handler( function($ex) use ( $self ) { if ( $self->isOn() ) { + /* + * Turning off 'html_errors' at this point avoids interference + * with xDebugs 'var_dump()'-overload, thus preserving prettyfied dumps + */ + @ini_set( 'html_errors', false ); $self->reportException( $ex ); } else { return false;