Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
joomlatools/joomlatools-framework#534: Use KODEKIT_DEBUG to set the d…
Browse files Browse the repository at this point in the history
…ebug mode and correctly figure out suppressed errors on PHP8
  • Loading branch information
ercanozkaya committed Sep 9, 2021
1 parent 184f0d6 commit 8b3e491
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions code/exception/handler/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,16 @@ public function _handleError($level, $message, $file, $line, array $context = nu

if($this->isEnabled(self::TYPE_ERROR))
{
$is_suppressed_error = error_reporting() === 0 || (error_reporting() < ($this->getErrorReporting() < 0 ? E_ALL : $this->getErrorReporting()));

/*
* Do not handle suppressed errors.
*
* error_reporting returns 0 if the statement causing the error was prepended by the @ error-control operator.
* @see : http://www.php.net/manual/en/language.operators.errorcontrol.php
* error_reporting returns 0 (or something lower than 4437 on PHP8) if the statement causing the error was prepended by the @ error-control operator.
* @see https://www.php.net/manual/en/language.operators.errorcontrol.php
* @see https://www.php.net/manual/en/language.operators.errorcontrol.php#125938
*/
if (!($this->_error_operator && error_reporting() === 0))
if (!($this->_error_operator && $is_suppressed_error))
{
if ($this->getErrorReporting() & $level)
{
Expand Down
2 changes: 1 addition & 1 deletion code/kodekit.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ final private function __construct($config = array())
if(isset($config['debug'])) {
self::$_debug = $config['debug'];
} else {
self::$_debug = false;
self::$_debug = (getenv('KODEKIT_DEBUG') !== false ? filter_var( getenv('KODEKIT_DEBUG') , FILTER_VALIDATE_BOOLEAN) : false);
}

if(isset($config['cache'])) {
Expand Down

0 comments on commit 8b3e491

Please sign in to comment.