Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a025b4

Browse filesBrowse files
committed
bug #34854 [Messenger] gracefully handle missing event dispatchers (xabbuh)
This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] gracefully handle missing event dispatchers | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34852 | License | MIT | Doc PR | Commits ------- d4ae85f gracefully handle missing event dispatchers
2 parents 2ac5609 + d4ae85f commit 9a025b4
Copy full SHA for 9a025b4
Expand file treeCollapse file tree

12 files changed

+82
-12
lines changed

‎src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ class SendMessageMiddleware implements MiddlewareInterface
3939
public function __construct(SendersLocatorInterface $sendersLocator, EventDispatcherInterface $eventDispatcher = null)
4040
{
4141
$this->sendersLocator = $sendersLocator;
42-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
42+
43+
if (null !== $eventDispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
44+
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
45+
} else {
46+
$this->eventDispatcher = $eventDispatcher;
47+
}
48+
4349
$this->logger = new NullLogger();
4450
}
4551

‎src/Symfony/Component/Messenger/Worker.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Worker.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ public function __construct(array $receivers, MessageBusInterface $bus, array $r
5252
$this->receivers = $receivers;
5353
$this->bus = $bus;
5454
$this->retryStrategies = $retryStrategies;
55-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
55+
56+
if (null !== $eventDispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
57+
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
58+
} else {
59+
$this->eventDispatcher = $eventDispatcher;
60+
}
61+
5662
$this->logger = $logger;
5763
}
5864

‎src/Symfony/Component/Security/Core/Authorization/Voter/TraceableVoter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Voter/TraceableVoter.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ class TraceableVoter implements VoterInterface
3131
public function __construct(VoterInterface $voter, EventDispatcherInterface $eventDispatcher)
3232
{
3333
$this->voter = $voter;
34-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
34+
35+
if (class_exists(LegacyEventDispatcherProxy::class)) {
36+
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
37+
} else {
38+
$this->eventDispatcher = $eventDispatcher;
39+
}
3540
}
3641

3742
public function vote(TokenInterface $token, $subject, array $attributes)

‎src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ class GuardAuthenticatorHandler
4646
public function __construct(TokenStorageInterface $tokenStorage, EventDispatcherInterface $eventDispatcher = null, array $statelessProviderKeys = [])
4747
{
4848
$this->tokenStorage = $tokenStorage;
49-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
49+
50+
if (null !== $eventDispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
51+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
52+
} else {
53+
$this->dispatcher = $eventDispatcher;
54+
}
55+
5056
$this->statelessProviderKeys = $statelessProviderKeys;
5157
}
5258

‎src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
9393
'require_previous_session' => true,
9494
], $options);
9595
$this->logger = $logger;
96-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
96+
97+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
98+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
99+
} else {
100+
$this->dispatcher = $dispatcher;
101+
}
102+
97103
$this->httpUtils = $httpUtils;
98104
}
99105

‎src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
5252
$this->authenticationManager = $authenticationManager;
5353
$this->providerKey = $providerKey;
5454
$this->logger = $logger;
55-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
55+
56+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
57+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
58+
} else {
59+
$this->dispatcher = $dispatcher;
60+
}
5661
}
5762

5863
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ public function __construct(TokenStorageInterface $tokenStorage, iterable $userP
6666
$this->userProviders = $userProviders;
6767
$this->sessionKey = '_security_'.$contextKey;
6868
$this->logger = $logger;
69-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
69+
70+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
71+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
72+
} else {
73+
$this->dispatcher = $dispatcher;
74+
}
75+
7076
$this->trustResolver = $trustResolver ?: new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class);
7177
}
7278

‎src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ public function __construct(TokenStorageInterface $tokenStorage, RememberMeServi
4949
$this->rememberMeServices = $rememberMeServices;
5050
$this->authenticationManager = $authenticationManager;
5151
$this->logger = $logger;
52-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
52+
53+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
54+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
55+
} else {
56+
$this->dispatcher = $dispatcher;
57+
}
58+
5359
$this->catchExceptions = $catchExceptions;
5460
$this->sessionStrategy = null === $sessionStrategy ? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE) : $sessionStrategy;
5561
}

‎src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
6565
$this->providerKey = $providerKey;
6666
$this->simpleAuthenticator = $simpleAuthenticator;
6767
$this->logger = $logger;
68-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
68+
69+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
70+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
71+
} else {
72+
$this->dispatcher = $dispatcher;
73+
}
74+
6975
$this->trustResolver = $trustResolver ?: new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class);
7076
}
7177

‎src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ public function __construct(TokenStorageInterface $tokenStorage, UserProviderInt
7070
$this->usernameParameter = $usernameParameter;
7171
$this->role = $role;
7272
$this->logger = $logger;
73-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
73+
74+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
75+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
76+
} else {
77+
$this->dispatcher = $dispatcher;
78+
}
79+
7480
$this->stateless = $stateless;
7581
}
7682

‎src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
6969
$this->successHandler = $successHandler;
7070
$this->failureHandler = $failureHandler;
7171
$this->logger = $logger;
72-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
72+
73+
if (null !== $eventDispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
74+
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
75+
} else {
76+
$this->eventDispatcher = $eventDispatcher;
77+
}
78+
7379
$this->options = array_merge(['username_path' => 'username', 'password_path' => 'password'], $options);
7480
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
7581
}

‎src/Symfony/Component/Workflow/Workflow.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Workflow.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ public function __construct(Definition $definition, MarkingStoreInterface $marki
4343
{
4444
$this->definition = $definition;
4545
$this->markingStore = $markingStore ?: new MultipleStateMarkingStore();
46-
$this->dispatcher = null !== $dispatcher ? LegacyEventDispatcherProxy::decorate($dispatcher) : null;
46+
47+
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
48+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
49+
} else {
50+
$this->dispatcher = $dispatcher;
51+
}
52+
4753
$this->name = $name;
4854
}
4955

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.