Make eventDispatcher compatible with "Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch()"

Created on 8 October 2022, about 2 years ago
Updated 21 July 2024, 4 months ago

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/stage_file_proxy/-/blob/8.x-1.x/src/E... gives this error when webprofiler module is enabled.

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 /var/www/html/public_html/modules/contrib/webprofiler/src/EventDispatcher/TraceableEventDispatcher.php) #0 /var/www/html/public_html/modules/contrib/stage_file_proxy/src/EventSubscriber/ProxySubscriber.php(122): Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch('stage_file_prox...', Object(Drupal\stage_file_proxy\EventDispatcher\AlterExcludedPathsEvent)) #1 [internal function]: Drupal\stage_file_proxy\EventSubscriber\ProxySubscriber->checkFileOrigin(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher)) #2 /var/www/html/public_html/modules/contrib/webprofiler/src/EventDispatcher/TraceableEventDispatcher.php(110): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher)) #3 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(135): Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request') #4 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #5 /var/www/html/public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #6 /var/www/html/public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #7 /var/www/html/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #8 /var/www/html/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #9 /var/www/html/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php(49): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #10 /var/www/html/public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #11 /var/www/html/public_html/modules/contrib/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #12 /var/www/html/public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #13 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /var/www/html/public_html/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /var/www/html/public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #16 {main}.

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

📌 Task
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇮🇹Italy emanuelrighetto Verona

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024