Skip to content

Overriding error handler changes symfony error handler #421

Closed as not planned
Closed as not planned
@simPod

Description

@simPod

When using older version of Sentry (v2) with Symfony (v5.2) the handler in DebugHandlersListener::configure() is

$handler = {array} [2]
 0 = {Symfony\Component\ErrorHandler\ErrorHandler} [18]
 1 = "handleException"

in Sentry v3 the ExceptionListenerIntegration overrides exception handler in registerOnceExceptionHandler() via line

self::$handlerInstance->previousExceptionHandler = set_exception_handler(\Closure::fromCallable([self::$handlerInstance, 'handleException']));

therefore the handler is now of type Closure, not array

image

And the condition in Symfony's DebugHandlersListener is not satisfied

        $handler = set_exception_handler('var_dump');
        $handler = \is_array($handler) ? $handler[0] : null;
        restore_exception_handler();

$handler is now null.

That kind of significantly influences the rest of app behaviour.

TBH I don't know what is the proper solution to the problem. Is it intended? I wish to keep Symfony error handler as I hook into its events.

Setting $handler to null forces symfony/debug's ErrorHandler to be used instead and I don't want that, it does not use onKernelException() listeners for example.

(

  - Upgrading sentry/sentry (2.5.0 => 3.1.2): Extracting archive
  - Upgrading sentry/sdk (2.2.0 => 3.1.0)
  - Upgrading sentry/sentry-symfony (3.5.2 => dev-master f34ebf2): Extracting archive

)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions