Connehito/cake-sentry

CakePHP 4.4: Use of `BaseErrorHandler` and subclasses are deprecated.

Closed this issue · 1 comments

Description

The file cake-sentry/config/bootstrap.php contains the following lines:

if ($isCli) {
    (new ConsoleErrorHandler(Configure::read('Error', [])))->register();
} else {
    (new ErrorHandler(Configure::read('Error', [])))->register();
}

These classes have been deprecated in CakePHP 4.4 and make my application crash with the following stack trace (simplified):

vendor/connehito/cake-sentry/src/Http/Client.php(144): Sentry\Severity::fromError('notice')
vendor/cakephp/cakephp/src/Error/BaseErrorHandler.php(94): deprecationWarning('Use of `BaseErrorHandler` and subclasses are deprecated...')
vendor/connehito/cake-sentry/config/bootstrap.php(22): Cake\Error\BaseErrorHandler->register()

How to reproduce

  • Create a CakePHP application.
  • Add connehito/cake-sentry to the application.
  • Add the following snippet to Application.php:
public function bootstrap(): void
{
    ...
    if (Configure::read('Environment') != 'localhost') {
        $this->addPlugin('Connehito/CakeSentry');
        $debugLogConfig = Log::getConfig('debug');
        $debugLogConfig['className'] = SentryLog::class;
        Log::drop('debug');
        Log::setConfig('debug', $debugLogConfig);
        \Cake\Event\EventManager::instance()->on(new \App\Log\SentryOptionsContext());
    }
}
  • Open the application in a browser.

See #74