Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moved turning off 'html_errors' into error/exception handlers, to preserve xDebug's prettyfied var_dump() #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/php_error.php
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ public static function identifyTypeHTML( $arg, $recurseLevels=1 ) {

private $classNotFoundException;

private $clearAllBuffers;

/**
* = Options =
*
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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 );
Expand All @@ -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.
*/
Expand All @@ -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;
Expand Down