TypeError: Drupal\eca\Event\TokenGenerateEvent::__construct

Created on 3 October 2024, 6 months ago

Problem/Motivation

An error occurs when displaying a node that has a paragraphs structure.

Steps to reproduce

If the $original variable is an array, we get this error.

In my case, the variable was:

Array
(
    [0] => [paragraph:field_menu_type:value]
    [1] => [paragraph:field_menu_type:value]
)

This data comes from linked_field custom link, based on something like this:

/node/[current-page:node:nid]/[paragraph:field_menu_type:value]?type=[paragraph:field_title_alt:value|paragraph:field_menu_type:value]

Maybe the problem is caused by linked_field and I will take a look.

But the site wasn't breaking until ECA was installed, so maybe this $original variable should be protected against other types:

in src/Token/TokenDecoratorTrait.php line 336

    if (1 === $this->recursionLevel) {
      foreach ($tokens as $name => $original) {
        $token_event = new TokenGenerateEvent($type, $name, $original, $data, $options, $bubbleable_metadata);
        $this->eventDispatcher->dispatch($token_event, EcaEvents::TOKEN);
        $data = $token_event->getData() + $data;
      }
    }
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇵🇹Portugal jrochate

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

Comments & Activities

Production build 0.71.5 2024