TypeError: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch(): Argument #1 ($event) must be of type object, string given

Created on 9 October 2023, about 1 year ago
Updated 20 April 2024, 7 months ago

Problem/Motivation

The following error occurs when you merge two terms (Drupal 10.1.4)

TypeError: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch(): Argument #1 ($event) must be of type object, string given, called in /app/web/modules/contrib/term_merge/src/TermMerger.php on line 106 in Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (line 89 of core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php).
Drupal\term_merge\TermMerger->mergeIntoTerm(Array, Object) (Line: 82)
Drupal\term_merge\TermMerger->mergeIntoNewTerm(Array, 'Term') (Line: 151)
Drupal\term_merge\Form\MergeTermsConfirm->submitForm(Array, Object)

Steps to reproduce

Select two terms you want to merge, complete the steps. When you confirm the error occurs.

Proposed resolution

Problem is that the two arguments in TermMerger.php:106 are in the wrong order:

Wrong:
$this->dispatcher->dispatch(TermMergeEventNames::TERMS_MERGED, $event);

Correct:
$this->dispatcher->dispatch($event, TermMergeEventNames::TERMS_MERGED);

🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇳🇱Netherlands Web-Beest

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

Comments & Activities

Production build 0.71.5 2024