mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 21:38:54 +00:00
[ticket/17176] Combine error handler with exception handling/msg_handler()
PHPBB3-17176
This commit is contained in:
parent
cf799897e2
commit
45cefd4433
3 changed files with 11 additions and 19 deletions
|
@ -97,14 +97,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
|
||||||
|
|
||||||
// Registered before building the container so the development environment stay capable of intercepting
|
// Registered before building the container so the development environment stay capable of intercepting
|
||||||
// the container builder exceptions.
|
// the container builder exceptions.
|
||||||
if (PHPBB_ENVIRONMENT === 'development')
|
\phpbb\debug\debug::enable(null, PHPBB_ENVIRONMENT === 'development');
|
||||||
{
|
|
||||||
\phpbb\debug\debug::enable();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
|
|
||||||
}
|
|
||||||
|
|
||||||
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
|
||||||
$phpbb_class_loader_ext->register();
|
$phpbb_class_loader_ext->register();
|
||||||
|
|
|
@ -65,15 +65,8 @@ class debug
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($displayErrors)
|
|
||||||
{
|
|
||||||
error_handler::register(new error_handler(new BufferingLogger(), true));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
error_handler::register()->throwAt(0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugClassLoader::enable();
|
DebugClassLoader::enable();
|
||||||
|
|
||||||
|
error_handler::register(new error_handler(new BufferingLogger(), $displayErrors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace phpbb\debug;
|
namespace phpbb\debug;
|
||||||
|
|
||||||
|
use Symfony\Component\ErrorHandler\BufferingLogger;
|
||||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,16 +21,21 @@ use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||||
*/
|
*/
|
||||||
class error_handler extends ErrorHandler
|
class error_handler extends ErrorHandler
|
||||||
{
|
{
|
||||||
|
public function __construct(BufferingLogger $bootstrappingLogger = null, private bool $debug = false)
|
||||||
|
{
|
||||||
|
parent::__construct($bootstrappingLogger, $debug);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-suppress MethodSignatureMismatch
|
* @psalm-suppress MethodSignatureMismatch
|
||||||
*/
|
*/
|
||||||
public function handleError(int $type, string $message, string $file, int $line): bool
|
public function handleError(int $type, string $message, string $file, int $line): bool
|
||||||
{
|
{
|
||||||
if ($type === E_USER_WARNING || $type === E_USER_NOTICE)
|
if (!$this->debug)
|
||||||
{
|
{
|
||||||
$handler = defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler';
|
$handler = defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler';
|
||||||
|
|
||||||
$handler($type, $message, $file, $line);
|
return $handler($type, $message, $file, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::handleError($type, $message, $file, $line);
|
return parent::handleError($type, $message, $file, $line);
|
||||||
|
|
Loading…
Add table
Reference in a new issue