Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[EventDispatcher] After upgrading to 3.3.0 removeSubscriber() does not work any more. #22970

Closed
@Gemineye

Description

@Gemineye
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.3.0

In some commands I use this kind of functionality to disable the sending of Emails:
$this->getContainer()->get('event_dispatcher')->removeSubscriber($this->getContainer()->get('my_email_subscriber'));

And then I put it back:

$this->getContainer()->get('event_dispatcher')->addSubscriber($this->getContainer()->get('my_email_subscriber'));

After some debugging I found out that the EventDispatcher now holds closures to enhance LazyLoading in the $this->listeners array.
So the array_search check does not work anymore in function removeListener.

I'm not sure if this really is a bug or if there is a new way now to achieve this.

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