From 236680ad7ad8c2430c99dde1a5f9b91452bb5b31 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 15 Aug 2022 23:40:50 +0200 Subject: [PATCH] throw error exceptions on error levels only --- Modules/Core/ShopControl_DebugBar.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Modules/Core/ShopControl_DebugBar.php b/Modules/Core/ShopControl_DebugBar.php index 7a0f83d..62efe6c 100644 --- a/Modules/Core/ShopControl_DebugBar.php +++ b/Modules/Core/ShopControl_DebugBar.php @@ -43,19 +43,22 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent public function d3DebugBarSetErrorHandler() { if ($this->d3CanActivateDebugBar()) { - set_error_handler( function( $severity, $message, $file, $line ) { - if ( ! ( error_reporting() & $severity ) ) { - // This error code is not included in error_reporting. - return; - } + set_error_handler( + function( $severity, $message, $file, $line ) { + if ( 0 === error_reporting() || !( error_reporting() & $severity ) ) { + // This error code is not included in error_reporting. + return false; + } - $smartyTemplate = $this->getSmartyTemplateLocationFromError( $message ); - if ( is_array( $smartyTemplate ) ) { - [ $file, $line ] = $smartyTemplate; - } + $smartyTemplate = $this->getSmartyTemplateLocationFromError( $message ); + if ( is_array( $smartyTemplate ) ) { + [ $file, $line ] = $smartyTemplate; + } - throw new ErrorException( $message, 0, $severity, $file, $line ); - } ); + throw new ErrorException( $message, 0, $severity, $file, $line ); + }, + E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR + ); } }