Skip to content

Commit a53732f

Browse files
committed
bug #33693 [Security] use LegacyEventDispatcherProxy (dmaicher)
This PR was merged into the 4.3 branch. Discussion ---------- [Security] use LegacyEventDispatcherProxy | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - I ran into an issue on one of my apps that has its own event dispatcher class using the old dispatch method signature ```php public function dispatch($eventName, Event $event = null) ``` This leads to ``` TypeError: Argument 2 passed to X\Tests\Base\TestEventDispatcher::dispatch() must be an instance of Symfony\Component\EventDispatcher\Event or null, string given, called in /var/www/x/symfony/vendor/symfony/security/Http/Firewall/ContextListener.php on line 230 /var/www/x/symfony/tests/Base/TestEventDispatcher.php:20 /var/www/x/symfony/vendor/symfony/security/Http/Firewall/ContextListener.php:230 /var/www/x/symfony/vendor/symfony/security/Http/Firewall/ContextListener.php:111 ``` since the event here is dispatched using the new signature: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Security/Http/Firewall/ContextListener.php#L259 Commits ------- 7067e48 [Security] use LegacyEventDispatcherProxy
2 parents e016145 + 7067e48 commit a53732f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Log\LoggerInterface;
1515
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
16+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1617
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1718
use Symfony\Component\HttpKernel\Event\RequestEvent;
1819
use Symfony\Component\HttpKernel\KernelEvents;
@@ -63,7 +64,7 @@ public function __construct(TokenStorageInterface $tokenStorage, iterable $userP
6364
$this->userProviders = $userProviders;
6465
$this->sessionKey = '_security_'.$contextKey;
6566
$this->logger = $logger;
66-
$this->dispatcher = $dispatcher;
67+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
6768
$this->trustResolver = $trustResolver ?: new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class);
6869
}
6970

0 commit comments

Comments
 (0)