Problem/Motivation
The Symfony dispatch() method notifies all listeners of the given event. It takes two arguments: the Event instance to pass to each listener of that event and the name of the event to dispatch.
https://git.drupalcode.org/project/csp/-/blob/8.x-1.x/src/EventSubscribe... gives this error when webprofiler module is enabled.
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to "Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch()" must be an object, string given. in Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch() (line 84 of modules/contrib/webprofiler/src/EventDispatcher/TraceableEventDispatcher.php).
Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch('csp.policy_alter', Object) (Line: 178)
Drupal\csp\EventSubscriber\ResponseCspSubscriber->onKernelResponse(Object, 'kernel.response', Object)
call_user_func(Array, Object, 'kernel.response', Object) (Line: 110)
Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch(Object, 'kernel.response') (Line: 192)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 180)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Require webprofiler module and enable it.
Proposed resolution
Change arguments order.
Remaining tasks
Review
User interface changes
None
API changes
None
Data model changes
None