Skip to content

[EventDispatcher] LegacyEventDispatcherProxy incompatible with WrappedListener #31457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
keulinho opened this issue May 10, 2019 · 0 comments
Closed

Comments

@keulinho
Copy link
Contributor

Symfony version(s) affected: 4.3.0

Description
The \Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy implements the EventDispatcherInterface from the Contracts Bundle, but the \Symfony\Component\EventDispatcher\Debug\WrappedListener expects the EventDispatcherInterface from the EventDispatcher Bundle in its __invoke() method.

This leads to the error below.

How to reporduce*
Dispatch an Event with the deprecated dispatch(Event $event) signature, when your are in a dev env.

Possible Solution
The \Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy should probably implement the EventDispatcherInterface from the EventDispatcher Bundle as it already implements all additional functions described by the EventDispatcherInterface from the EventDispatcher Bundle compared to the interface from the Contracts Bundle.

Additional context

PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Argument 3 passed to Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke() must implement interface Symfony\Component\EventDispatcher\EventDispatcherInterface, instance of Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy given, called in /app/vendor/symfony/event-dispatcher/LegacyEventDispatcherProxy.php on line 78 in /app/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:113
        Stack trace:
        #0 /app/vendor/symfony/event-dispatcher/LegacyEventDispatcherProxy.php(78): Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(Object(Symfony\Component\Console\Event\ConsoleErrorEvent), 'console.error', Object(Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy))
        #1 /app/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php(168): Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy->dispatch(Object(Symfony\Component\Console\Event\ConsoleErrorEvent), 'console.error')
        #2 /app/vendor/sym in /app/vendor/symfony/event-dispatcher/Debug/WrappedListener.php on line 113
@keulinho keulinho changed the title LegacyEventDispatcherProxy incompatible with WrappedListener [EventDispatcher] LegacyEventDispatcherProxy incompatible with WrappedListener May 10, 2019
keulinho added a commit to keulinho/symfony that referenced this issue May 10, 2019
The `LegacyEventDispatcherProxy` now implements the full
`EventDispatcherInterface` from the `EventDispatcherBundle`.
Before it just implemented the Interface from the `Contracts` Bundle,
that made it incompatible with the `WrappedListener`.
This fixes symfony#31457.
keulinho added a commit to keulinho/symfony that referenced this issue May 10, 2019
The `LegacyEventDispatcherProxy` now implements the full
`EventDispatcherInterface` from the `EventDispatcherBundle`.
Before it just implemented the Interface from the `Contracts` Bundle,
that made it incompatible with the `WrappedListener`.
This fixes symfony#31457.
@fabpot fabpot closed this as completed May 13, 2019
fabpot added a commit that referenced this issue May 13, 2019
…linho)

This PR was merged into the 4.3 branch.

Discussion
----------

Fix the interface incompatibility of EventDispatchers

The `LegacyEventDispatcherProxy` now implements the full
`EventDispatcherInterface` from the `EventDispatcherBundle`.
Before it just implemented the Interface from the `Contracts` Bundle,
that made it incompatible with the `WrappedListener`.
This fixes #31457.

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31457
| License       | MIT
| Doc PR        | /

Commits
-------

bdeeae1 Fix the interface incompatibility of EventDispatchers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants