From 19cf0fc14c00c9bc8ca8ac8f9d4699c5ded19714 Mon Sep 17 00:00:00 2001 From: David Wosnitza Date: Sun, 23 Dec 2012 08:35:55 +0100 Subject: [PATCH 1/2] moved turning off 'html_errors' into error/exception handlers, to preserve xDebug's prettyfied var_dump() --- src/php_error.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/php_error.php b/src/php_error.php index fa55cd5..47c992e 100644 --- a/src/php_error.php +++ b/src/php_error.php @@ -2620,7 +2620,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 +2639,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 +2661,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; From b8cbfb30199eca8a1b8edc185252e8ca9022020e Mon Sep 17 00:00:00 2001 From: David Wosnitza Date: Sun, 23 Dec 2012 11:56:47 +0100 Subject: [PATCH 2/2] added option to clear all opened buffers --- src/php_error.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/php_error.php b/src/php_error.php index 47c992e..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 = '';