Skip to content

Typed property Symfony\Component\Cache\Adapter\TraceableAdapterEvent::$end must not be accessed before initialization #48910

@Bilge

Description

@Bilge

Symfony version(s) affected

6.2.4

Description

When an exception is thrown in debug mode in the callback passed to Symfony\Contracts\Cache\CacheInterface::get(string $key, callable $callback), Symfony will end up masking the exception with its own as CacheDataCollector throws the following exception:

Typed property Symfony\Component\Cache\Adapter\TraceableAdapterEvent::$end must not be accessed before initialization in symfony\cache\DataCollector\CacheDataCollector.php on line 118.

$statistics[$name]['time'] += $call->end - $call->start;

How to reproduce

Probably something like the following should get it to trigger, although in my testing, it does not.

$cache->get(
    'foo',
    function (ItemInterface $item) {
        throw new \Exception;
    }
);

I am not sure what it is about my app in particular that triggers it, but the exception is actually thrown from a fiber, in case that matters. Here's a snapshot of $calls.

image

Possible Solution

No response

Additional Context

This does not happen on Symfony 5.4; the correct userland exception message and trace is shown, instead of one coming from Symfony's components.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions