TypeError $event_dispatcher must be of type ContainerAwareEventDispatcher

Created on 24 April 2024, 7 months ago
Updated 12 August 2024, 3 months ago

Problem/Motivation

Just installed the module on a Drupal 10.3.x site, enabled some options in the configuration, added the field, added a node, and got this fatal error:

TypeError: Drupal\forward\Form\ForwardForm::__construct(): Argument #11 ($event_dispatcher) must be of type Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher, Symfony\Component\EventDispatcher\EventDispatcher given, called in /var/www/html/web/modules/contrib/forward/src/Form/ForwardForm.php on line 237 in Drupal\forward\Form\ForwardForm->__construct() (line 182 of modules/contrib/forward/src/Form/ForwardForm.php).
Drupal\forward\Form\ForwardForm::create(Object) (Line: 41)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('\Drupal\forward\Form\ForwardForm') (Line: 48)
Drupal\Core\Controller\HtmlFormController->getFormObject(Object, '\Drupal\forward\Form\ForwardForm') (Line: 58)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 637)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->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: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 736)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
🐛 Bug report
Status

Needs work

Version

4.0

Component

Code

Created by

🇮🇹Italy kopeboy Milan

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

Merge Requests

Comments & Activities

  • Issue created by @kopeboy
  • Assigned to praveen rani
  • Merge request !4Update ForwardForm.php → (Open) created by praveen rani
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 7 months ago
    2 pass
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • To resolve the above issue, I have created MR. Please review changes.

  • Status changed to Needs work 6 months ago
  • 🇺🇸United States john.oltman

    Thanks for the MR. There are a few issues that need fixing:

    * Should be a blank line above the comment block above the class and after the last use statement (used to be there)
    * The old use statement for ContainerAwareEventDispatcher can be removed
    * The doc block for the __construct needs to be updated for the $event_dispatcher variable

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 6 months ago
    2 pass
  • Status changed to Needs review 6 months ago
  • 🇮🇳India atul_ghate

    I have fixed the issue as per drupal coding standard, please review.

  • 🇮🇳India rajdip_755 kolkata

    Hi everyone!

    I'm trying to review the MR 4 but I'm unable to reproduce the same issue mentioned in the description.

    1. While I'm trying to replicate the by installing the latest version of this module(4.0.2) using the composer then getting a different issue. The screenshot of the issue attached herewith
    2. But, if we are trying to replicate by cloning the target branch i.e 4.0.x of this project, then none of the issue is encountered.

    It will be helpful if someone please mention the steps to reproduce for the issue mentioned in the description.

    Thanks in advance!

  • Status changed to Needs work 4 months ago
  • 🇺🇸United States john.oltman

    The order of the parameters to the "dispatch" function is now backwards when using the new interface - they need to be reversed. Setting issue back to "needs work" so the MR can be adjusted.

  • 🇨🇦Canada brunodbo

    I am seeing the same error as mentioned in #8. As @rajdip_755 says in his comment, the fix for that problem (i.e., changing the dispatch() method's argument order, as mentioned in #9) is already in the 4.0.x branch (see https://git.drupalcode.org/project/forward/-/commit/322887d1df607c30fa2b...), so I think all that needs to be done is roll a new release that includes the fix. Raising this to critical as this prevents the module from functioning currently.

Production build 0.71.5 2024