Skip to content

Error: Call to a member function getWrappedListener() on a non-object #12845

Closed
@pjordaan

Description

@pjordaan

I run symfony 2.5, but I should do tests to see from which version it occurs or see if 2.6 fixed this issue. I get this fatal error:

Error: Call to a member function getWrappedListener() on a non-object in vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php line 229

After some debugging I found out what caused this error. I had a service that added a new listener to kernel.response in the constructor and the service was instantiated when the kernel.response event was being triggered.

TraceableEventDispatcher::postProcess expects that all listeners registered are wrapped with WrappedListener, but since a new listener was added after preProcess ran this is not the case.

I could fix this easily by adding

if (!$listener instanceof WrappedListener) {
    contnue;
}

in the foreach loop in postProcess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions